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

player move to tile

New Here ,
Jun 07, 2013 Jun 07, 2013

I have a player movie clip and a tile movieclip. When I click the tile movieclip, it adds buttons on the screen. When I click the button, I want the player to go to that tile movieclip that was clicked, however, it isn't working.

function mouseclick(event:MouseEvent)

                              {

                                                  (event.currentTarget as Tile).outline.gotoAndStop("active");

                                                  addChild(skip_btn);

                                                  skip_btn.buttonMode = true;

                                                  ////////////////SKIP BUTTON FUNCTIONALITY/////////////////////

                                                  if (player.x == (event.currentTarget.x) && player.y == (event.currentTarget.y)) {

                                                            skip_btn.buttonMode = false;

                                                            skip_btn.gotoAndStop("inactive");

                                                  }

                                                  else {

                                                            skip_btn.gotoAndStop("out");

                                                            skip_btn.buttonMode = true;

                                                  }

                              }

if (skip_btn.skipClick == true){

                                                            removeChild(skip_btn);

                                                            player.x = (event.currentTarget.x);

  player.y = (event.currentTarget.y);

                                                            trace("MOVE!");

                                                            skip_btn.skipClick = false;

                                                  }

Basically if a player is on a tile and you click that tile, then the button appears, but it isn't clickable. If you click another tile that the player is not on, then it is clickable and the player should move there, but it doesn't. Any ideas on how to get this to work?

TOPICS
ActionScript
596
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
Community Expert ,
Jun 07, 2013 Jun 07, 2013

i assume you're posting your tile listener function and have not posted the button's listener function. 

in the tile listener function i do not see that you're saving a reference to the tile so it's not clear how the button's listener function will know which tile to go to.  you probably need to fix that and you should post your button's listener function.

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
New Here ,
Jun 07, 2013 Jun 07, 2013

The button's listener function just declares a variable called skipClip true. To save a reference, should I create a new variable(let's call it tileSelected) that's a boolean and when the tile is clicked, say event.currentTarget.tileSelected = true?

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
Community Expert ,
Jun 08, 2013 Jun 08, 2013
LATEST

if the button's listener function resets skipClip, how is mouseclick called AFTER that listener function executes?

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