0
我想在flash cs6中開發一個plataform遊戲。我創建了一個名爲Plataforma的類,其中一個名爲enterFrameEvents的方法可用於驗證此類的平臺是否與mario相沖突。馬里奧穿過平臺的頂部,即使檢測到碰撞(flash CS6)
但是,無論我做什麼,它都會檢測到馬里奧已經與其頂部相撞,但馬里奧穿過平臺。但是當他與底部和其他部分碰撞時不會發生。
我粘貼鏈接我的代碼https://www.4shared.com/rar/jqa5oRGWei/AULA_6.html
在臺上有兩個藍色的平臺,這是「PLATAFORMA」符號ocorrences。 Plataforma類是由flash爲「plataforma」符號自動生成的一個actionscript類。
在這裏,我將代碼粘貼
private function enterFrameEvents(event:Event):void{
if(this.hitTestObject(mario)){
// collision with top
if(mario.y + mario.height >= this.y && mario.y <= this.y &&
mario.x + mario.width >= this.x + 5 && mario.x <= this.x + this.width - 5){
_root.isJumping = false;
_root.speedY = 0;
mario.y = this.y - mario.height;
}
...
}
我從角落折扣5個像素。
謝謝!
我覺得這** mario.y = this.y - mario.height; **瞬移你的馬里奧向上穿過平臺。或許應該是** mario.y = this.y; **。 – Organis