Author Topic: Making a view not load until a button is pressed.  (Read 987 times)

gavdra

  • Guest
Making a view not load until a button is pressed.
« 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!
« Last Edit: January 03, 2013, 03:48:44 pm by gavdra »

DeadSn0wMan

  • Guest
Re: Making a view not load until a button is pressed.
« Reply #1 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
« Last Edit: January 03, 2013, 04:01:18 pm by DeadSn0wMan »

gavdra

  • Guest
Re: Making a view not load until a button is pressed.
« Reply #2 on: January 03, 2013, 07:58:15 pm »
Thanks a ton! That works perfectly