| 赞 | 3 |
| VIP | 333 |
| 好人卡 | 2 |
| 积分 | 1 |
| 经验 | 1450446 |
| 最后登录 | 2019-5-29 |
| 在线时间 | 615 小时 |
Lv1.梦旅人 66RPG站长
- 梦石
- 0
- 星屑
- 54
- 在线时间
- 615 小时
- 注册时间
- 2005-10-10
- 帖子
- 5734
  
|
如果你的人物是固定的位置就比较简单:分两段做:一个是人物发射激光,一个是画面的激光飞舞。
否则的话也有一些别的办法,比如对特定动画设置一个偏移。主要在module RPG里面的Animation和Sprite < ::Sprite里面。我们可以进行修改,然后用“发动特技,100”来控制播放的时候动画播放位置比数据库设置时候的中心位置偏移100象素。
做了一个简单的范例工程如下:
http://rpg.blue/upload_program/files/Project_shift_animation.rar
脚本如下(修改的地方已经标注出来了):
- module RPG
- class Animation
- # --------------------------------------
- # 添加一个根据动画名称决定的偏移X的变量
- # --------------------------------------
- def shift_x
- return @name.split(/,/)[1] != nil ? @name.split(/,/)[1].to_i : 0
- end
- end
-
-
- class Sprite < ::Sprite
- def initialize(viewport = nil)
- super(viewport)
- @_whiten_duration = 0
- @_appear_duration = 0
- @_escape_duration = 0
- @_collapse_duration = 0
- @_damage_duration = 0
- @_animation_duration = 0
- @_blink = false
-
- # ---------------------------------
- # 添加一个偏移X的变量
- # ---------------------------------
- @_animation_shiftx = 0
-
- end
-
- def animation(animation, hit)
- dispose_animation
- @_animation = animation
-
- # ---------------------------------
- # 读取偏移X的变量
- # ---------------------------------
- @_animation_shift_x = animation.shift_x
-
- return if @_animation == nil
- @_animation_hit = hit
- @_animation_duration = @_animation.frame_max
- animation_name = @_animation.animation_name
- animation_hue = @_animation.animation_hue
- bitmap = RPG::Cache.animation(animation_name, animation_hue)
- if @@_reference_count.include?(bitmap)
- @@_reference_count[bitmap] += 1
- else
- @@_reference_count[bitmap] = 1
- end
- @_animation_sprites = []
- if @_animation.position != 3 or not @@_animations.include?(animation)
- for i in 0..15
- sprite = ::Sprite.new(self.viewport)
- sprite.bitmap = bitmap
- sprite.visible = false
- @_animation_sprites.push(sprite)
- end
- unless @@_animations.include?(animation)
- @@_animations.push(animation)
- end
- end
- update_animation
- end
-
- def animation_set_sprites(sprites, cell_data, position)
- for i in 0..15
- sprite = sprites[i]
- pattern = cell_data[i, 0]
- if sprite == nil or pattern == nil or pattern == -1
- sprite.visible = false if sprite != nil
- next
- end
- sprite.visible = true
- sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
- if position == 3
- if self.viewport != nil
- sprite.x = self.viewport.rect.width / 2
- sprite.y = self.viewport.rect.height - 160
- else
- sprite.x = 320
- sprite.y = 240
- end
- else
- sprite.x = self.x - self.ox + self.src_rect.width / 2
- sprite.y = self.y - self.oy + self.src_rect.height / 2
- sprite.y -= self.src_rect.height / 4 if position == 0
- sprite.y += self.src_rect.height / 4 if position == 2
- end
- #-------------------------------------------------
- # 给动画的X添加偏移
- #-------------------------------------------------
- sprite.x += cell_data[i, 1] + @_animation_shift_x
-
- sprite.y += cell_data[i, 2]
- sprite.z = 2000
- sprite.ox = 96
- sprite.oy = 96
- sprite.zoom_x = cell_data[i, 3] / 100.0
- sprite.zoom_y = cell_data[i, 3] / 100.0
- sprite.angle = cell_data[i, 4]
- sprite.mirror = (cell_data[i, 5] == 1)
- sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
- sprite.blend_type = cell_data[i, 7]
- end
- end
-
- end
- end
复制代码 |
|