[]请问object层中添加的sprite怎么添加点击事件
Object层是tiledmap最上面的一层,其中添加了一个sprite对象,但是给这个sprite添加鼠标点击事件不起作用,请大神看看
mallLayer = tiledMap.getLayerByName("Object");
budai = tiledMap.getLayerObject("Object","budai");
var flower = new Sprite();
flower.loadImage("res/ui/npc/budai/stand_ld1.png");
flower.pos(budai.x, budai.y);
flower.alpha=1;
flower.pivotX=25;
flower.pivotY=80;
flower.zOrder = budai.y;
flower.autoSize = true;
flower.height = 100;
flower.width = 100;
flower.size(100,100);
flower.on(Laya.Event.CLICK,this,function()
{
alert("My Name is Bear");
});
mallLayer.addChild(flower);
mallLayer._showGridList.push(flower);
mallLayer = tiledMap.getLayerByName("Object");
budai = tiledMap.getLayerObject("Object","budai");
var flower = new Sprite();
flower.loadImage("res/ui/npc/budai/stand_ld1.png");
flower.pos(budai.x, budai.y);
flower.alpha=1;
flower.pivotX=25;
flower.pivotY=80;
flower.zOrder = budai.y;
flower.autoSize = true;
flower.height = 100;
flower.width = 100;
flower.size(100,100);
flower.on(Laya.Event.CLICK,this,function()
{
alert("My Name is Bear");
});
mallLayer.addChild(flower);
mallLayer._showGridList.push(flower);
没有找到相关结果
已邀请:
5 个回复
Aar0n
赞同来自: 158*****197
Aar0n
赞同来自:
Aar0n
赞同来自:
158*****197
赞同来自:
158*****197
赞同来自:
budai对象在最上面这层的Object里面 应该不会被遮挡哦