Project1

标题: 怎么让图片摇动 [打印本页]

作者: 火焰卷轴    时间: 2012-8-23 19:17
标题: 怎么让图片摇动
我在事件内显示一张图片
然后执行事件震动,没有效果
请问要怎么摇动  
作者: 猪衰衰    时间: 2012-8-23 19:21
在并行事件里移动图片就行了.
作者: Luciffer    时间: 2012-8-23 22:07
手动设置事件,左右摇动或者上下摇动只要调节成微幅度移动就好了
另外,楼主发帖时请使用发帖按钮中的发起求助功能,谢谢配合。
作者: 杰总    时间: 2012-8-23 22:16
新手看这,介样发表求助6R会白送你50经验悬赏的
这样会有更多人会愿意帮你 懂?

看这.png (23.04 KB, 下载次数: 21)

~~~~

~~~~

作者: 1396    时间: 2012-8-24 09:09
用画面震动。
作者: R-零    时间: 2012-8-24 09:45
特别帮你写了一段,里面用的是正弦函数来控制震动。因此需要四个参数
调用方法 $game_map.screen.pictures[图片编号].shake("x"和"y"中任选一个,振动幅度,振动速度,振动时间) #震动幅度数值建议在2~20之间,振动速度建议设定在10~120之间
  1. class Game_Picture
  2.   alias sakuya_init initialize
  3.   def initialize(number)
  4.     sakuya_init(number)
  5.     @shake_d = "x"
  6.     @shake_T = 0
  7.     @shake_t = 0
  8.     @shake_r = 0
  9.     @shake_tx = 0
  10.   end
  11.   def shake(a,b=1,c=1,d=20)
  12.     @shake_d = a
  13.     @shake_r = c
  14.     @shake_T = b
  15.     @shake_t = 0
  16.     @shake_tx = d
  17.   end
  18.   def get_exxy
  19.     return [0,0] if @shake_tx == 0
  20.     @shake_t += 1
  21.     if @shake_t == @shake_tx
  22.       @shake_t = @shake_tx = 0
  23.     end
  24.     l = 180 / 3.14
  25.     del = @shake_r * Math.sin(@shake_t*@shake_T/l)
  26.     case @shake_d
  27.     when "x"
  28.       return [del,0]
  29.     when "y"
  30.       return [0,del]
  31.     end
  32.   end
  33. end
  34. class Sprite_Picture < Sprite
  35.   #--------------------------------------------------------------------------
  36.   # ● 更新画面
  37.   #--------------------------------------------------------------------------
  38.   def update
  39.     super
  40.     if @picture_name != @picture.name
  41.       @picture_name = @picture.name
  42.       if @picture_name != ""
  43.         self.bitmap = Cache.picture(@picture_name)
  44.       end
  45.     end
  46.     if @picture_name == ""
  47.       self.visible = false
  48.     else
  49.       self.visible = true
  50.       if @picture.origin == 0
  51.         self.ox = 0
  52.         self.oy = 0
  53.       else
  54.         self.ox = self.bitmap.width / 2
  55.         self.oy = self.bitmap.height / 2
  56.       end
  57.       del = @picture.get_exxy
  58.       self.x = @picture.x + del[0]
  59.       self.y = @picture.y + del[1]
  60.       self.z = 100 + @picture.number
  61.       self.zoom_x = @picture.zoom_x / 100.0
  62.       self.zoom_y = @picture.zoom_y / 100.0
  63.       self.opacity = @picture.opacity
  64.       self.blend_type = @picture.blend_type
  65.       self.angle = @picture.angle
  66.       self.tone = @picture.tone
  67.     end
  68.   end
  69. end
复制代码
下面是范例,里面的断头骷髅禁止搬运
Project13.7z (400.11 KB, 下载次数: 77)

@火焰卷轴
作者: 火焰卷轴    时间: 2012-8-25 18:33
R-零 发表于 2012-8-24 07:45
特别帮你写了一段,里面用的是正弦函数来控制震动。因此需要四个参数
调用方法 $game_map.screen.pictures[ ...

感谢





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