大三了開了cocos二維游戲技術課
我的腦海有個宏大計劃終于可以做游戲了

破碎騎士這個名字來源小組成員石興的靈感:掉落記憶的騎士
我們打算做一款動作,冒險格斗,又充滿溫情的人生第一款游戲;
然而進度條好快,這學期要過半了
啊,好慢花了一個月只做了第一個場景的一部分

- 鏡頭跟隨
- 碰撞盒子
- 影片打擊,跑,站立
- 音效部分的加入{素材真不好找啊,啊sir}
代碼放在下面了(注意:我的代碼來源于模仿B站up主阿信B站傳送門)
hero主角部分
const Input={};
const State={
stand:1,
attack:2,
};
cc.Class({
extends: cc.Component,
properties: {
swordAudio: {
default: null,
type: cc.AudioClip
},
runAudio: {
default: null,
type: cc.AudioClip
}
},
onLoad() {
this._speed=200;
this.heroState=State.stand;
this.anima='idle';
this.combo=0;
this.heroAni=this.node.getComponent(cc.Animation);
this.heroAni.on('finished',this.onAnimaFinished,this)
cc.systemEvent.on('keydown',this.onKeydown,this);
cc.systemEvent.on('keyup',this.onKeyup,this);
},
onDestroy(){
this.heroAni.off('finished',this.onAnimaFinished,this)
},
onAnimaFinished(e,data)
{
if(data.name=='attack'||data.name=='attack2'||data.name=='attack3')
{
this.heroState=State.stand;
this.combo=(this.combo+1)%3;
setTimeout(()=>{
if(this.heroState==State.attack)return;
this.combo=0;
},500);
}
},
setAni(anima){
if(this.anima==anima)return;
this.anima=anima;
this.heroAni.play(anima);
},
onKeydown(e)
{Input[e.keyCode]=1;
},
onKeyup(e){
Input[e.keyCode]=0;
},
update (dt) {
let anima=this.anima;
let scaleX=Math.abs(this.node.scaleX);
let scaleY=Math.abs(this.node.scaleY);
//狀態切換
switch(this.heroState)
{
case State.stand:{
if(Input[cc.macro.KEY.j]){
this.heroState=State.attack;
cc.audioEngine.playEffect(this.swordAudio, false);//呼叫音頻
}
break;
}
}
//攻擊
if(this.heroState==State.attack)
{
if(Input[cc.macro.KEY.j]){
if(this.combo==0)
{
anima='attack';
}else if(this.combo==1)
{anima='attack2';
}else if(this.combo==2)
{ anima='attack3';}
}
}
//移動
if(this.heroState!=State.stand)
{
//this.sp.x=0;
}
else{
if(Input[cc.macro.KEY.a]||Input[cc.macro.KEY.left])
{
this.node.scaleX=-scaleX;
this.node.x-=this._speed*dt;
anima='run';
}
else if(Input[cc.macro.KEY.d]||Input[cc.macro.KEY.right])
{this.node.scaleX=scaleX;
this.node.x+=this._speed*dt;
anima='run';}
else{anima='idle';}
}
if(anima)
{
this.setAni(anima);
}
},
});
- 麻煩的事:沒有合適的音效素材
- 沒有合適的UI素材一切變得困難
影片,人物素材,地圖在外網上倒是白嫖到了免費的資源(國外的游戲氛圍真好啊!)
11月21日更新

把游戲界面設計出來了
游戲界面的logo交給汪洋去做
在這里我用了日式RPG作曲大師石元丈晴的《我ら來たれり》作為游戲界面加載的音樂,不得不說,大師的音樂都太有味了
按鈕加入了hover屬性,感覺更好看了,不會死板,雖然純手畫
-
設計了大概四種





轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/226319.html
標籤:其他
