最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

橡皮怪Dici,over,welcome,player

运维笔记admin24浏览0评论

橡皮怪Dici,over,welcome,player

橡皮怪Dici,over,welcome,player

Dici

cc.Class({extends: cc.Component,properties:{//主角遇刺音效dieAudio:{default:null,url:cc.AudioClip},},onLoad: function () {//计时器this.schedule(this.setDiciMove,1);//为屏幕设置触摸侦听事件,控制地刺移动this.node.parent.on(cc.Node.EventType.MOUSE_ENTER,this.setDiciMove.bind(this),this);},//设置地刺移动setDiciMove:function(){     var goAction= cc.moveBy(1,cc.p(-960,0));this.node.runAction(goAction);},//返回地刺在世界坐标中的包围盒noteBox:function(){return this.node.getBoundingBoxToWorld();},update: function (dt) {var player = cc.find("Canvas/player").getComponent("Player");if(cc.rectIntersectsRect(player.node.getBoundingBoxToWorld(),this.noteBox())){cc.audioEngine.playEffect(this.dieAudio,false);//cc.director.loadScene('over');}if(this.node.y > cc.winSize.height/2){this.node.destroy();}},
});```**over**

cc.Class({
extends: cc.Component,

properties: 
{scoreLabel:cc.Label,     //本轮得分文本button:cc.Node,          //重新开始按钮highScoreLab:cc.Label,   //最高分文本breakRecordParticle:cc.ParticleSystem,
},breakRecordAction:function()
{var action1 = cc.scaleTo(0.2,1.2);var action2 = cc.scaleTo(0.2,1);var seq = cc.sequence(action1, action2);var repeat = cc.repeatForever(seq);return repeat;
},onLoad: function () 
{this.breakRecordParticle.enabled = false;var highScore = cc.sys.localStorage.getItem("highScore") || 0;var score = cc.sys.localStorage.getItem("score");cc.director.preloadScene("game");if(Number(highScore) < Number(score)){this.breakRecordParticle.enabled = true;this.highScoreLab.node.runAction(this.breakRecordAction());cc.sys.localStorage.setItem("highScore",Number(score));}highScore = cc.sys.localStorage.getItem("highScore");this.highScoreLab.string = "HighScore: " + highScore;this.scoreLabel.string = "本轮得分:"+score;this.button.on("touchstart",function(){cc.director.loadScene("game");});
},

});


**welcome**

cc.Class({
extends: cc.Component,
properties:
{
//背景音乐
bgAudio:
{
default:null,
url:cc.AudioClip
},
//按钮图标
startBtn: cc.Node,
},

onLoad: function () 
{cc.audioEngine.playMusic(this.bgAudio,true);cc.director.preloadScene("game");var scaleTo = cc.scaleTo(0.8,0.9);var reverse = cc.scaleTo(0.8,1);var seq = cc.sequence(scaleTo,reverse);var repeat = cc.repeatForever(seq);this.startBtn.runAction(repeat);this.startBtn.on("touchstart",function(){cc.audioEngine.pauseMusic();cc.director.loadScene("game");});
},

});

**player**

cc.Class({
extends: cc.Component,

properties: {},onLoad: function (){},noteBox:function()
{return this.node.getBoundingBox();
}

});
“`

发布评论

评论列表(0)

  1. 暂无评论