欢迎来到程序小院
接鸡冠
玩法:左右移动棒棒君(小海豹)接住鸡冠,避开炸弹,若不小心接住炸弹则游戏结束,
赶紧接鸡冠吧,看看你能够接住多少鸡冠哦^^。。
开始游戏https://www.ormcc.com/play/gameStart/211
html
<div id="game-box"></div>
css
canvas{display: block;touch-action: none;user-select: none;-webkit-tap-highlight-color: rgba(0, 0, 0, 0);width: 320px;height: 508px;cursor: inherit;margin-top: 0px;
}
js
game.physics.startSystem(Phaser.Physics.ARCADE);
// 背景
this.bg = game.add.sprite(0, 0, 'loadbg');
this.bg.width = _width;
this.bg.height = _height + dheight;
// 地面
this.ground = game.add.sprite(0, game.height, 'ground');
this.ground.anchor.set(0, 1);
this.ground.width = game.width;
this.ground.height = 195 / unit;
game.physics.arcade.enable(this.ground);
//鼹鼠
this.bang = game.add.sprite(game.world.centerX, game.height - 178 / unit, 'allbang');
this.bang.anchor.set(0.5, 1);
this.bang.width = 260 / unit;
this.bang.height = 440 / unit;
this.bang.animations.add('bangrun', runArr);
this.bang.animations.add('bangget', getArr);
this.bang.animations.add('banglose', loseArr);
this.bang.animations.play('bangrun', 20, true);
game.physics.arcade.enable(this.bang);
this.bang.body.width = 220 / unit;
this.bang.body.height = 400 / unit;
this.bang.body.offset.set(20 / unit, 20 / unit);
this.bang.body.collideWorldBounds = true;this.onStart();//音乐控制
this.voiceBtn = game.add.sprite(923 / unit, 45 / unit, 'voice', 1);
this.voiceBtn.width = 105 / unit;
this.voiceBtn.height = 105 / unit;
this.voiceBtn.inputEnabled = true;
this.voiceBtn.events.onInputDown.add(game.bgmControl, this);
//分数
this.showScore = game.add.sprite();
this.scoreBox = game.add.sprite(25 / unit, 20 / unit, 'scorebox');
this.scoreBox.width = 525 / unit;
this.scoreBox.height = 157 / unit;
this.showScore.addChild(this.scoreBox);
this.score = game.add.retroFont('score', 32, 62, "0123456789", 10, 0, 0);
this.score.setFixedWidth(320, Phaser.RetroFont.ALIGN_RIGHT);
this.score.text = "0";
this.num = game.add.image(200 / unit, 86 / unit, this.score);
this.num.scale.set(1 / unit);
this.showScore.addChild(this.num);
this.showScore.bringToTop();
//音效
this.getbgm = game.add.audio('get', 0.2, false);
this.boombgm = game.add.audio('boom', 0.2, false);
this.losebgm = game.add.audio('lose', 0.2, false);//游戏结束弹窗
this.overPopup = game.add.group();
this.overBox = game.add.image(46 / unit, 321 / unit, 'overbox');
this.overBox.width = 989 / unit;
this.overBox.height = 1068 / unit;
this.overPopup.add(this.overBox);
this.overscore = game.add.retroFont('overscore', 32, 62, "0123456789", 10, 0, 0);
this.overnum = game.add.image(603 / unit, 564 / unit, this.overscore);
this.overnum.scale.set(1 / unit);
this.overPopup.add(this.overnum);
this.againBtn = game.add.button(315 / unit, 695 / unit, 'again', function () {this.losebgm.stop();clickbgm.play();setTimeout(function () {game.state.start('game');if (!game.musicPause) {bgm.play();}}, 1000);
}, this);
this.againBtn.width = 477 / unit;
this.againBtn.height = 163 / unit;
this.overPopup.add(this.againBtn);
this.linkBtn = game.add.button(729 / unit, 1065 / unit, 'link', function () {}, this);
this.linkBtn.width = 240 / unit;
this.linkBtn.height = 60 / unit;
this.overPopup.add(this.linkBtn);
this.overPopup.visible = false;
源码
需要源码请关注添加好友哦^ ^
转载:欢迎来到本站,转载请注明文章出处
https://ormcc.com/