Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

addChild and globaltoLocal

New Here ,
Aug 18, 2013 Aug 18, 2013

I have an enemy that adds an attack movie clip. More specifically, this attack movie (We'll call it masterAttack) clip is a blank movie clip that acts like a super class, that will hold other attacks like a weak and strong attack. So when my enemy attacks using a timer, it adds the masterAttack on a global to local point. My problem is, on the first run, the masterAttack will attack the player wherever it is, then remove itself, which is good. Then the next time it runs,  the masterAttack is not hitting the player. It's as if the globaltoLocal isn't working after the first run.

Below is the Enemy timer attacking a tile the player is on:

if (Main.tileset.tileMiddle.hitTestObject(Main.player.visionPoint))

{

         this.addChild(masterAttack);

         var pt:Point = this.masterAttack.globalToLocal(new Point(Main.tileset.x, Main.tileset.y));

         masterAttack.masterEnemyAttackTimer.start();

         this.masterAttack.x = (pt.x);

         this.masterAttack.y = (pt.y);

}

And Below is the masterAttack timer:

function mastertimer(event:TimerEvent) {

                              addChild(sludgeball); //This is one of the many attacks pickable by the masterAttack

                              sludgeball.enemyattackTimer.start();

                              if (this.sludgeball.currentLabel == "End") {

                                        this.sludgeball.gotoAndPlay(1);

                                        masterEnemyAttackTimer.stop();

                              if (masterEnemyAttackTimer.running == false)

                              {

                                        attackStop = true;

                                        this.parent.removeChild(this);

                                        removeChild(sludgeball);

                              }

                    }

TOPICS
ActionScript
266
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation