- 注册时间
- 2013-2-13
- 最后登录
- 2023-10-13
- 阅读权限
- 200
- 积分
- 9312
- 精华
- 1
- 帖子
- 2411
|
s42249 发表于 2014-9-4 15:09
init(1000 / 60, 'legend',480, 756, main);
var con;
var a;
这是因为对象被遮挡住了的问题
如果以我的demo为例,解决的办法,
1,在点击对象的时候,利用setChildIndex对对象进行排序,让被拖动的对象位于最上层- LInit(1000/50,"legend",800,450,main);
- function main(){
- LMultitouch.inputMode = LMultitouchInputMode.TOUCH_POINT;
- for(var i=0;i<3;i++){
- var child = new LSprite();
- child.x = 250*i;
- child.graphics.drawRect(2,"#ff0000",[0,0,100,100],true,"#ff0000");
- child.addEventListener(LMouseEvent.MOUSE_DOWN,ondown);
- child.addEventListener(LMouseEvent.MOUSE_UP,onup);
- addChild(child);
- }
- }
- function ondown(e){
- e.target.parent.setChildIndex(e.target,e.target.parent.numChildren - 1);
- e.target.startDrag(e.touchPointID);
- }
- function onup(e){
- e.target.stopDrag();
- }
复制代码 运行如下
http://lufylegend.com/demo/test/52.html
2,可以将鼠标弹起事件,加到父容器上- LInit(1000/50,"legend",800,450,main);
- //此变量用来保存正在拖动的对象
- var dragObject;
- function main(){
- LMultitouch.inputMode = LMultitouchInputMode.TOUCH_POINT;
- var layer = new LSprite();
- addChild(layer);
- for(var i=0;i<3;i++){
- var child = new LSprite();
- child.x = 250*i;
- child.graphics.drawRect(2,"#ff0000",[0,0,100,100],true,"#ff0000");
- child.addEventListener(LMouseEvent.MOUSE_DOWN,ondown);
- layer.addChild(child);
- }
- layer.addEventListener(LMouseEvent.MOUSE_UP,onup);
- }
- function ondown(e){
- dragObject = e.target;
- e.target.startDrag(e.touchPointID);
- }
- function onup(e){
- dragObject.stopDrag();
- }
复制代码 运行如下
http://lufylegend.com/demo/test/51.html
|
|