Animate object only once per room visit when player walks into a region

Started by DoctorDan, Sun 08/06/2014 17:01:59

Previous topic - Next topic

DoctorDan


I struggling to make an animation run just once per room visit. When the player enters a region in the room the animation is triggered. The problem I'm having is that if the player should backtrack over the same region the animation will trigger again ruining the effect. The script so far is as below with the object's visibility originally set to "false".

Code: ags
function region3_WalksOnto()
{
  obirdflight.Visible = true;
  obirdflight.SetView(9);
  obirdflight.Animate(0, 3, eOnce, eBlock);
}

Khris

Do this:

Code: ags
bool bird_shown;  // this line outside any function, somewhere before
                  // room_Load() and region3_WalksOnto()

function room_Load()
{
  bird_shown = false;  // if you already have room_Load(), just add this line anywhere inside
                       // otherwise create and link it the usual way first
}

function region3_WalksOnto()
{
  if (bird_shown) return;  // exit here
  obirdflight.Visible = true;
  obirdflight.SetView(9);
  obirdflight.Animate(0, 3, eOnce, eBlock);
  bird_shown = true;
}


SMF spam blocked by CleanTalk