第五节 木槌敲打地鼠的打击效果动画制作
- 游戏得分飘字效果
小锤子锤击地鼠的效果
游戏得分飘字效果
导入资源 刷新 将+100移动到相应位置
分别选中其他的box Ctrl+Shift+V 粘贴+100 导出
本节代码放在最后
小锤子锤击地鼠的效果
新建页面
改变锤子的中心点 var=hammer
改变旋转角度 移动位置到合适位置
第二帧 设置锤子抬起状态
第五帧 还原第一帧锤子的状态
点击播放自己进行操作修改
改名
保存 导出代码
在src下新建Hammer.js
Hammer.js
var Hammer=(function(_super){
function Hammer(){
Hammer.super(this);
}
Laya.class(Hammer,"Hammer",_super);
var _proto=Hammer.prototype;
//开始使用
_proto.start=function(){
Laya.Mouse.hide();
Laya.stage.on(Laya.Event.MOUSE_DOWN,this,this.onMouseDown);
Laya.stage.on(Laya.Event.MOUSE_MOVE,this,this.onMouseMove);
}
//结束使用
_proto.end=function(){
Laya.mouse.show();
Laya.stage.off(Laya.Event.MOUSE_DOWN,this,this.onMouseDown);
Laya.stage.off(Laya.Event.MOUSE_MOVE,this,this.onMouseMove);
}
_proto.onMouseDown=function(){
this.hit.play(0,false);
}
_proto.onMouseMove