Project1

标题: 请问怎么在脚本中调用方法? [打印本页]

作者: wbsy8241    时间: 2009-6-9 01:39
标题: 请问怎么在脚本中调用方法?
我初学脚本 写了3个方便点的显示图片
  1.   #-------------------------------------
  2.   # ● 自定义显示图片
  3.   #-------------------------------------
  4.   def pi(name, x, y)
  5.     @name = name
  6.     @x = x.to_f
  7.     @y = y.to_f
  8.   end
  9.   #-------------------------------------
  10.   # ● 自定义移动图片
  11.   #-------------------------------------
  12.   def mv(y)
  13.     @duration = 2
  14.     @target_x = x
  15.     @target_y = y.to_f
  16.     @target_opacity = 255
  17.   end
  18.   #-------------------------------------
  19.   # ● 自定义消失图片
  20.   #-------------------------------------
  21.   def me
  22.     @duration = 4
  23.     @target_opacity = 0
  24.   end
复制代码

在事件脚本中这样写:
$game_screen.pictures[41].pi($y)
$y -= 10
$game_screen.pictures[41].mv($y)
@wait_count = 2
$y += 12
$game_screen.pictures[41].mv($y)
@wait_count = 20
$game_screen.pictures[41].me
效果是让1幅图片 往上跳出来 在往下降 等一会消失
因为会执行多张这种图,用了等待以后 $y 会被改变

如何才能整和到1个方法中?
  def ph
    $game_screen.pictures[41].pi(y)
    $game_screen.pictures[41].mv(y)
    y -= 10
    @wait_count = 2
    $game_screen.pictures[41].mv(y)
    @wait_count = 20
    y += 12
    $game_screen.pictures[41].me(y)
  end

或者可不可以定义方法的时候直接定义出这种效果?


[LINE]1,#dddddd[/LINE]

自己解决了.
  1.     if @new >= 1
  2.       if @new >= 27
  3.       @y -= 3
  4.       elsif @new >= 24
  5.       @y += 3
  6.       elsif @new <= 3
  7.       @opacity -= 96
  8.       end
  9.       @new -= 1
  10.     end
复制代码

作者: goahead    时间: 2009-6-9 01:43
提示: 作者被禁止或删除 内容自动屏蔽
作者: wbsy8241    时间: 2009-6-9 01:47
以下引用goahead于2009-6-8 17:43:48的发言:

写个专业用来显示数字动画的sprite
参考F1里的 RPG::Sprite


还不太会 改显示图片的比较简单- -





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