Project1

标题: 求大神写个动画脚本 [打印本页]

作者: 够爱    时间: 2018-4-29 00:40
标题: 求大神写个动画脚本
系统动画效果如图动画图层在角色图层之上    我想做个法阵类的动画效果   就是角色图层高于动画图层  起到类似于动画角色在背后的效果
希望动画图片名称加个前缀就能实现这个功能      求懂脚本的大神帮忙写下

224236uo8rl5qu9791rj2z.png (69.69 KB, 下载次数: 40)

224236uo8rl5qu9791rj2z.png

作者: gforce    时间: 2018-4-29 00:40
新建了个工程试了下还是在角色图层上边


我也想不出原因...直接给你工程好了

test.png (368.28 KB, 下载次数: 39)

test.png

Project2.rar

1.31 MB, 下载次数: 125


作者: 够爱    时间: 2018-4-29 00:41
有其他办法或通过脚本实现也行
作者:  眠     时间: 2018-4-29 07:52
把法阵连同人物一起做成行走图。
使用的时候就事件→改变行走图。
作者: 卫宫白    时间: 2018-4-29 08:06
就横版战斗系统就行。在横版基础里设定好你的魔法阵动画,再在横版设定中写入启用就行了

作者: 够爱    时间: 2018-4-29 10:54
 眠  发表于 2018-4-29 07:52
把法阵连同人物一起做成行走图。
使用的时候就事件→改变行走图。

这个方法可行是可行   但是量太大了
作者: 够爱    时间: 2018-4-29 10:55
卫宫白 发表于 2018-4-29 08:06
就横版战斗系统就行。在横版基础里设定好你的魔法阵动画,再在横版设定中写入启用就行了
...

我是纵版战斗系统  所以想能不能通过写脚本加个前缀解决这个问题
作者: 够爱    时间: 2018-4-29 11:00
说明下  战斗系统是纵版的
作者: gforce    时间: 2018-4-29 13:35
本帖最后由 gforce 于 2018-4-29 13:38 编辑

随意修改了一下,希望没BUG
动画名子加上<U>即可

  1. class Sprite_Base < Sprite
  2.   alias ori_start_animation start_animation
  3.   def start_animation(animation, mirror = false)
  4.     ori_start_animation(animation, mirror = false)
  5.     if @animation
  6.       @animation.name =~ /<U>/ ? @ani_z = -10 : @ani_z = 300
  7.     end
  8.   end
  9.   
  10.   def animation_set_sprites(frame)#只改了一行
  11.     cell_data = frame.cell_data
  12.     @ani_sprites.each_with_index do |sprite, i|
  13.       next unless sprite
  14.       pattern = cell_data[i, 0]
  15.       if !pattern || pattern < 0
  16.         sprite.visible = false
  17.         next
  18.       end
  19.       sprite.bitmap = pattern < 100 ? @ani_bitmap1 : @ani_bitmap2
  20.       sprite.visible = true
  21.       sprite.src_rect.set(pattern % 5 * 192,
  22.         pattern % 100 / 5 * 192, 192, 192)
  23.       if @ani_mirror
  24.         sprite.x = @ani_ox - cell_data[i, 1]
  25.         sprite.y = @ani_oy + cell_data[i, 2]
  26.         sprite.angle = (360 - cell_data[i, 4])
  27.         sprite.mirror = (cell_data[i, 5] == 0)
  28.       else
  29.         sprite.x = @ani_ox + cell_data[i, 1]
  30.         sprite.y = @ani_oy + cell_data[i, 2]
  31.         sprite.angle = cell_data[i, 4]
  32.         sprite.mirror = (cell_data[i, 5] == 1)
  33.       end
  34.       sprite.z = self.z + @ani_z + i ##sprite.z = self.z + 300 + i
  35.       sprite.ox = 96
  36.       sprite.oy = 96
  37.       sprite.zoom_x = cell_data[i, 3] / 100.0
  38.       sprite.zoom_y = cell_data[i, 3] / 100.0
  39.       sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  40.       sprite.blend_type = cell_data[i, 7]
  41.     end
  42.   end  
  43. end
复制代码

作者: 够爱    时间: 2018-4-29 13:52
gforce 发表于 2018-4-29 13:35
随意修改了一下,希望没BUG
动画名子加上即可

请问大神是在动画名称前加<U>
还是在动画的图片名称前加<U>
作者: 够爱    时间: 2018-4-29 14:12
gforce 发表于 2018-4-29 13:35
随意修改了一下,希望没BUG
动画名子加上即可

还是不行    动画图层还是在角色图层之上  不知道是不是我用法错误

${CD~7XR%N8SBSO2MPPF[OJ.png (40.44 KB, 下载次数: 26)

${CD~7XR%N8SBSO2MPPF[OJ.png

VSCUAE)$MOHBPA37SQL_DSN.jpg (20.45 KB, 下载次数: 30)

VSCUAE)$MOHBPA37SQL_DSN.jpg

作者: 仲秋启明    时间: 2018-4-29 15:35
Sprite_Base里
164行改成animation_set_sprites(@animation.frames[frame_index],@animation.id)
183行def animation_set_sprites(frame,animation_id)
184行加一句@animation_id = animation_id
207行“sprite.z = self.z + 300 + i”那里加类似
  1. if @animation_id == 数据库里动画的id
  2. sprite.z = self.z - 100 + i
  3. else
  4. sprite.z = self.z + 300 + i
  5. end
复制代码

或者
  1. case @animation_id
  2. when 1,2
  3. self.z - 100 + i
  4. else
  5. sprite.z = self.z + 300 + i
  6. end
复制代码

的判定就行了
作者: 够爱    时间: 2018-4-29 15:43
仲秋启明 发表于 2018-4-29 15:35
Sprite_Base里
164行改成animation_set_sprites(@animation.frames[frame_index],@animation.id)
183行def  ...

谢谢大神   
看的并不是很懂    这是在原脚本里修改吗? 怕会出现bug或是出现全部动画变底层了的问题
所以希望是通过添加一个脚本  然后通过加前缀等方法 达到部分动画在底层的效果  
作者: 够爱    时间: 2018-4-29 16:21
够爱 发表于 2018-4-29 14:12
还是不行    动画图层还是在角色图层之上  不知道是不是我用法错误

那我新建个工程试试看
作者: 够爱    时间: 2018-4-29 16:26
够爱 发表于 2018-4-29 14:12
还是不行    动画图层还是在角色图层之上  不知道是不是我用法错误

新建了个工程试了下还是在角色图层上边  
作者: 够爱    时间: 2018-4-29 17:18
gforce 发表于 2018-4-29 16:35
我也想不出原因...直接给你工程好了

对的  想要的就是您范例中这种效果  可是我的工程还是一直不行  可能和战斗系统啥的脚本冲突了吧   不过还是谢谢了




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1