我想刪除名爲'_pokemon'的對象。如果被雨打落十次,稱爲'_jednaLinia'(意思是'_oneLine'),它應該被移除。我確實使用了這個代碼,是的,它做了我的_pokemon消失的工作,但它仍然在handleColisin函數中被檢測到。而主類仍然不斷提及它,因爲我得到了口袋妖怪類此錯誤「錯誤#1009:無法訪問空對象引用的屬性或方法」hittest,removechild,不可見對象保持問題,閃存,as3
我不幹新AS3和嘗試了許多簡單的解決方案,但似乎沒有工作,我打算如何。 如果可能請回答。
## some code I think is necessary, not all of it
...
public class Main extends Sprite
{
private var _pokemon:Pokemon;
public function Main():void
{
_starTimer = new Timer(30);
addEventListener(Event.ADDED_TO_STAGE, init);
_starTimer.addEventListener(TimerEvent.TIMER, start);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
_starTimer.start();
this.addChild(_pokemon);
}
...and further...
private function _pokemonLive(e:Event = null):void
{
decreaseLive--;
if (decreaseLive == 0)
{
_pokemon.parent.removeChild(_pokemon);/i think i tried all methods
_starTimer.stop();
}
}
而且就像我剛纔提到的。口袋妖怪課上有錯誤,它上面有隨機移動功能。這是1009錯誤的地方。如有需要,我發送更多的代碼。
當你叫_pokemonLive?它是一個事件監聽器嗎? – 2013-05-12 16:35:56
這部分激活_pokemonLive的代碼位於privat函數中,該函數使用timeEvent監聽器調用,並命名爲「start」'code'.................. if(_pokemon。 hitTestObject(_linia [COUNT])) \t \t \t { \t \t \t handleCollision(_linia [COUNT]); \t \t \t \t _pokemonLive(); \t \t \t \t \t \t} – derkarol 2013-05-12 19:55:55
看看我的答案,它應該工作,然後接受它。 – 2013-05-12 21:05:09