0
我對Flash完全陌生,並且正在嘗試在FlashDevelop中學習ActionScript3的FlashPunk。 我一直在使用本教程(http://dev.tutsplus.com/tutorials/an-introduction-to-flashpunk-the-basics--active-9638),並在第10步:碰撞。「未定義屬性的訪問」錯誤AS3 FlashPunk
它曾經說過要向World.as類中添加一些代碼,但是當我這樣做時,出現錯誤「Error:Access of undefined property _gameEntity」。這也發生在_box上。
我猜這是與變量被私人定義有關,因此World.as無法訪問它們。
override public function update():void
{
// update the entities
var e:Entity = _updateFirst;
while (e)
{
if (e.active)
{
if (e._tween) e.updateTweens();
e.update();
}
if (e._graphic && e._graphic.active) e._graphic.update();
e = e._updateNext;
}
//collisions
super.update();
var entityArray:Array = [];
getType("GameEntity", entityArray);
for each (var entity:Entity in entityArray)
{
entity.x = entity.x > 550 ? 550 : entity.x;
entity.y = entity.y > 400 ? 400 : entity.y;
}
if (_gameEntity.collideWith(_box, _gameEntity.x, _gameEntity.y))
{
trace("Collision!");
}
}
任何幫助表示讚賞:)
這就是我有,我_gameEntity和_box都在功能之前,這一點和世界後延定義:公共類遊戲世界擴展的世界 \t { \t \t私人VAR _gameEntity:GameEntity; \t \t \t \t private var _box:Box; \t \t \t 公共\t功能遊戲世界() \t \t { \t \t \t _gameEntity =新GameEntity(); \t \t \t _box = new Box(); \t \t \t \t \t \t add(_gameEntity); \t \t \t add(_box); \t \t \t \t \t \t _box.x = 200; \t \t \t _box.y = 150; \t \t \t \t \t \t addGraphic(新的圖像(圖像),0,50,50); \t \t} – user2078994
我不知所措。我無法下載flashpunk,因爲官方網站壞了(從來不是一個好兆頭)。嘗試評論你認爲可能導致問題的代碼行,直到錯誤消失,然後你會更好地瞭解在哪裏尋找錯誤。我將從步驟10中添加的代碼開始。對不起,我無法提供更多幫助。 – Frankenscarf
好的,謝謝你的幫助:) – user2078994