打造属于你的打地鼠游戏:从基础到进阶
在游戏开发的世界里,打地鼠游戏是一个经典且有趣的项目。它不仅能让我们体验到开发的乐趣,还能帮助我们掌握游戏开发的一些基本技巧。下面,我们就一起来看看如何一步步打造一个属于自己的打地鼠游戏。
1. 让小机器人出现
首先,我们要对 Pit 类进行修改,让小机器人能够出现。具体操作如下:
1. 修改 Pit 类,使其在当前帧是前四帧之一时切换到小机器人的下一帧。代码如下:
Pit = Class.create(Sprite,{
initialize:function(x,y){
//Call the Sprite class (super class) constructor
enchant.Sprite.call(this,48,48);
this.image = game.assets['mogura.png'];
this.x = x;
this.y = y;
//Defines an event listener to run every frame
this.addEventListener('enterframe',this.tick);
},
tick:function(){
this.frame++;
//Loop the animation once complete
if(this.frame>=4)th
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



