我想從我的播放器類調用打孔功能在另一個類中,但由於某種原因,它給了我這個錯誤:1180:調用可能未定義的方法打孔
1180: Call to a possibly undefined method Punch.
我不知道爲什麼它給了我這個錯誤。我甚至公開了這些職能。
這是我從調用它的類:
package
{
public class Player extends MovieClip
{
public function Player()
{
stage.addEventListener(KeyboardEvent.KEY_DOWN,KeyDown);
stage.addEventListener(KeyboardEvent.KEY_DOWN,KeyPressed);
addEventListener(Event.ENTER_FRAME,Update);
}
function KeyPressed(event:KeyboardEvent):void
{
//If on floor
if (CanJump)
{
//If A key is down
if (event.keyCode == 65)
{
//Punch
Punch(true);
}
}
}
function Update(event:Event)
{
//Do stuff
}
}
}
,這就是我試圖撥打:
package
{
public class ComboSequence extends ComboHandler
{
public function ComboSequence(clipName:String, par:BaseObject, _oList:ObjectList)
{
// constructor code
super(clipName, par, _oList);
}
public function Punch(PunchKey:Boolean)
{
if (currentAttack != null)
{
if (Recovery <= 0 && FollowUpTime > 0)
{
currentAttack = currentAttack.GetNextAttack(PunchKey);
if (currentAttack != null)
{
SetAnimation(currentAttack.animName);
Recovery = currentAttack.Recovery;
FollowUpTime = currentAttack.Recovery + 25;
}
}
}
if (FollowUpTime > 0)
{
FollowUpTime--;
}
else
{
currentAttack = null;
}
if (Recovery > 0)
{
Recovery--;
}
}
}
}
感謝,但我得到新的錯誤我加入這個 '公共變種comboSequence:ComboSequence =新ComboSequence(clipName:字符串,面值:BaseObject,_oList:鏈表類);' ,因爲它需要有三個參數,但現在我得到說期待錯誤直腸結腸前。什麼是右鍵盤 – Saf
聽起來就像你在語言的基礎知識方面有問題。我強烈建議你通過初學者的ActionScript教程。如果這是您的第一個項目,請嘗試更簡單的方法,並在您更有信心時加以解決。 – andypaxo