1、请列举出6个常用的鼠标事件,并说明具体作用?
click:单击鼠标左键
mousedown:按下鼠标左键
mouseup:松开鼠标左键
mousemove:移动鼠标
mouseover:鼠标进入
mouseout:鼠标离开
2、请列举出3个常用的移动设备触屏事件,并说明具体作用?
touchstart:触碰屏幕
touchend:手指离开屏幕
touchmove:手指移动
3、现有背景图片bg,请写出给背景图片bg添加鼠标点击事件的代码?
bg.interactive = true;bg.on("click",function(){代码;});
4、现有飞机图片plane,请写出设置飞机图片plane锚点坐标x、y都为0.5的相关代码?
plane.anchor.set(0.5,0.5);
//或者
plane.anchor.x = 0.5;
plane.anchor.y = 0.5;
5、请写出通过鼠标事件对象event,获得鼠标坐标信息的代码?
bg.interactive = true;
bg.on("mousemove",function(event){
var pos = event.data.getLocalPosition(app.stage);
});
6、请简单描述,将某一显示元素添加给舞台或者是添加给其他显示元素,二者的区别?
当我们将显示元素添加给其他显示元素时:
1) 当前显示元素会跟随其他显示元素的移动而移动。
2) 当前显示元素将不再以窗口的左上角为坐标原点,而是以其他显示元素的锚点为坐标原点。
