| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 1 |
| 经验 | |
| 最后登录 | 2014-2-21 |
| 在线时间 | 28 小时 |
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 28 小时
- 注册时间
- 2011-1-12
- 回帖
- 42
|
发表于 2011-7-26 13:14:49
|
显示全部楼层
class Note
def initialize(time, speed_x, speed_y)
@time = time
@speed_x = speed_x
@speed_y = speed_y
end
attr_reader :time # 开始时间
attr_reader :speed_x # x 轴移动速度
attr_reader :speed_y # y 轴移动速度
end
class Pic
def initialize(pic, notes)
@pic = pic # 图片
@notes = notes #移动节点
end
attr_accessor :pic # x 轴移动速度
attr_reader :notes # y 轴移动速度
end
abc = Sprite.new
abc.bitmap = Bitmap.new("1.png")
abcs = Sprite.new
abcs.bitmap = Bitmap.new("2.png")
$pic = []
$pic << Pic.new(abc, Note(0, 1, 1))
$pic << Pic.new(abcs, Note(0, 2, 2))
60.times do |times| # 60 秒更新
Graphics.update
$pic.each do |pics|
next times > pics.notes.time
pics.pic.x += pics.notes.x
pics.pic.y += pics.notes.y
end
end |
|