当前位置: 首页 > news >正文

AnimateCC及CreateJS:打飞机的4版本V1、V2、V3、V4

版本1:

this.btnGun.addEventListener("click", shootBomb);
var _this = this;
var bomb = new lib.bomblink();
bomb.alpha = 0;
bomb.rotation = 45;
bomb.scaleX = 0.2;
bomb.scaleY = 0.2;
_this.txtObj.text=""
stage.addChild(bomb);
createjs.Tween.get(this.planeObj, {loop: true
}).to({x: 700,y: 20
}, 1600);
createjs.Ticker.addEventListener("tick", handleTick);
function shootBomb() {_this.txtObj.text="发射!";bomb.x = 620;bomb.y = 420;bomb.alpha = 1;createjs.Tween.get(bomb, {loop: false}).to({x: 0,y: -400}, 900).call(finished);stage.update();
}
function finished() {bomb.alpha = 0;_this.txtObj.text="发射完毕!";
}
function handleTick() {var pt = bomb.localToLocal(0, 0,_this.planeObj);if (_this.planeObj.hitTest(pt.x, pt.y)==true&&bomb.alpha==1) {		_this.txtObj.text="命中!"stage.update();}
}
stage.update();

版本2:

this.btnGun.addEventListener("click", shootBomb);
var _this = this;
var bomb = new lib.bomblink();
bomb.alpha = 0;
bomb.rotation = 45;
bomb.scaleX = 0.2;
bomb.scaleY = 0.2;
_this.txtObj.text=""
stage.addChild(bomb);
var blast = new lib.blastlink();
stage.addChild(blast);
blast.gotoAndStop(0);
createjs.Tween.get(this.planeObj, {loop: true
}).to({x: 700,y: 20
}, 1600);
createjs.Ticker.addEventListener("tick", handleTick);
function shootBomb() {_this.txtObj.text="发射!";bomb.x = 620;bomb.y = 420;	bomb.alpha=1;createjs.Tween.get(bomb, {loop: false}).to({x: 0,y: -400}, 900).call(finished);stage.update();
}
function finished() {bomb.alpha = 0;	_this.txtObj.text="发射完毕!";
}
function handleTick() {var pt = bomb.localToLocal(0, 0,_this.planeObj); if (_this.planeObj.hitTest(pt.x, pt.y)==true&&bomb.alpha==1) {		_this.txtObj.text="命中!"blast.x=bomb.x;blast.y=bomb.y;		blast.gotoAndPlay(1);stage.update();}
}
stage.update();

版本3:

this.btnGun.addEventListener("click", shootBomb);
var _this = this;
var bomb = new lib.bomblink();
bomb.alpha = 0;
bomb.rotation = 45;
bomb.scaleX = 0.2;
bomb.scaleY = 0.2;
_this.txtObj.text = ""
stage.addChild(bomb);
var blast = new lib.blastlink();
stage.addChild(blast);
blast.gotoAndStop(0);_this.planeObj.rotation=0;_this.planeObj.alpha=1;_this.planeObj.x=-240;_this.planeObj.y=96
createjs.Tween.get(this.planeObj, {loop: true
}).to({x: 700,y: 20
}, 1600);
createjs.Ticker.addEventListener("tick", handleTick);
function shootBomb() {_this.txtObj.text = "发射!";bomb.x = 620;bomb.y = 420;bomb.alpha = 1;createjs.Tween.get(bomb, {loop: false}).to({x: 0,y: -400}, 900).call(finished);stage.update();
}
function finished() {bomb.alpha = 0;	_this.txtObj.text = "发射完毕!";
}
function downed() {	_this.planeObj.rotation=0;_this.planeObj.alpha=1;_this.planeObj.x=-240;_this.planeObj.y=96createjs.Tween.get(_this.planeObj, {loop: true
}).to({x: 700,y: 20
}, 1600);
}
function handleTick() {var pt = bomb.localToLocal(0, 0, _this.planeObj);if (_this.planeObj.hitTest(pt.x, pt.y) == true && bomb.alpha == 1) {_this.txtObj.text = "命中!";blast.x = bomb.x;blast.y = bomb.y;blast.gotoAndPlay(1);planeDown();stage.update();}
}
function planeDown() {_this.planeObj.rotation=30;createjs.Tween.get(_this.planeObj, {loop: false}).to({y: 800}, 1000).call(downed);
}
stage.update();

版本:4:

加相关的音效效果,待写......

设计界面: 

 源码下载:

https://download.csdn.net/download/vinglemar/91009540

http://www.dtcms.com/a/250515.html

相关文章:

  • hot100 -- 12.栈系列
  • 金蝶云星空BOS开发
  • Linux进程间通信(IPC)详解:从入门到理解
  • 深度分析Javascript中的Promise
  • 人工智能学习19-Pandas-设置
  • 当遇到“提交失败:404”的问题时,通常表明前端请求的URL无法正确匹配到后端的Servlet或资源。
  • aflplusplus:开源的模糊测试工具!全参数详细教程!Kali Linux教程!(四)
  • 【办公类-25-05】20250514 Python模拟UIBOT上传园园通截图(自动最小化界面,时间部分的删除和黏贴)
  • SCADA|KingSCADA对比显示任意几条实时曲线的方法
  • 理论物理学中的规范场论与全息原理
  • Go语言底层(五): 深入浅出Go语言的ants协程池
  • C#最佳实践:推荐使用泛型而非装箱、拆箱
  • 华为云Flexus+DeepSeek征文 | 基于Dify构建股票分析助手
  • 语音交互革命:基于 Amazon Nova Sonic + MCP 构建下一代沉浸式 Agent
  • LLMs 系列实操科普(6)
  • 嵌入式学习
  • 德国马克斯·普朗克数学研究所:几何朗兰兹猜想
  • JS进阶 Day03
  • 深度理解 CLIP:连接图像与语言的桥梁
  • 人工智能学习26-BP梯度下降
  • 【C语言】计算机组成、计算机语言介绍
  • 华为云Flexus+DeepSeek征文|基于华为云Flexus云服务的Dify一键部署
  • 遥控电风扇
  • OAC: Output-adaptive Calibration for Accurate Post-training Quantization
  • Python爬虫实战:研究simpleq相关技术
  • HTML+CSS 动态背景框动态登录注册框
  • C语言环形数组(循环队列)详解:原理、实现与应用
  • 山东大学软件学院创新项目实训开发日志——第十七周
  • 同步与异步编程范式全景研究——从CPU时钟周期到云原生架构的范式演进
  • 2025-06-14[避坑]解决不支持中文路径读取图像的方法