赞 | 0 |
VIP | 0 |
好人卡 | 3 |
积分 | 1 |
经验 | 5576 |
最后登录 | 2017-5-20 |
在线时间 | 246 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 246 小时
- 注册时间
- 2008-8-6
- 帖子
- 99
|
3楼
楼主 |
发表于 2011-7-29 22:14:18
|
只看该作者
下面给出拖曳代码以及某次运行的输出- def update
- if CGSSConfig.in_dev?
- endDragging if Mouse.pos == nil # 移出游戏窗口外也算放下
- if Mouse.down?(Mouse::LKEY)
- # 寻找第一个被拖住的层
- layer = @layers.find {|layer| Mouse.area?(layer.x,layer.y,layer.width,layer.height)}
- beginDragging(layer) if (layer !=nil)
- STDERR << "down\n"
- elsif Mouse.up?(Mouse::LKEY)
- endDragging
- STDERR << "up\n"
- elsif Mouse.press?(Mouse::LKEY)
- if self.dragging? # 正在拖动
- @draggingLayer.x += Mouse.pos[0] - @lastMousePos[0]
- @draggingLayer.y += Mouse.pos[1] - @lastMousePos[1]
- end
- else
- endDragging
- end
- @lastMousePos = Mouse.pos
- end
- end
- def beginDragging(layer)
- self.dragging = true
- @draggingLayer = layer
- end
- def endDragging
- self.dragging = false
- @draggingLayer = nil
- end
复制代码- down
- up
- down
- up
- down
- down
- down
- down
- up
- down
- down
- down
- down
- down
- up
- down
- up
- up
- down
- down
- down
- up
- down
- up
- up
- down
- up
- up
- up
- down
- up
- down
- down
- up
- up
- down
- up
- down
- up
- down
- up
- up
- up
- down
- up
- down
- up
- up
- up
- up
- down
复制代码 |
|