DragonFireSDK Forum

Programming Discussions => Game Programming => Topic started by: gavdra on January 03, 2013, 03:20:28 pm

Title: Making a view not load until a button is pressed.
Post by: gavdra on January 03, 2013, 03:20:28 pm
I am trying to make a game where a ball is moving around the screen. I have a button (the play button) that when i press it, it makes one container invisible which shows a screen that has a ball moving on it. I want the ball to start in the top left of the screen but the second the app loads the ball starts its movement(even though you cannot see it) so if i wait a few seconds before pressing the play button the ball is gone because it already started its moving. How could i fix this? THANKYOU IN ADVANCE!
Title: Re: Making a view not load until a button is pressed.
Post by: DeadSn0wMan on January 03, 2013, 03:59:18 pm
Using a booleon could be one easy fix for it. (Presuming you are not using Box2D)


Code: [Select]
bool isStarted = false;


void Play()
{
      //all of your container code
      isStarted = true;
}



OnTimer()
{
       if(isStarted)
       {
             //all the code to move the ball
       }

}



And just set the booleon to false when you want to stop the ball
Title: Re: Making a view not load until a button is pressed.
Post by: gavdra on January 03, 2013, 07:58:15 pm
Thanks a ton! That works perfectly