Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

dennizzz

how to change scene

This topic is 5530 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello... i wonder if there is there a way to change scene after x amount of time.. for example: in scene 1 i want a bouncing ball and after a while a want the ball to disapear and a other object would apear.. how do I do it? could i make to scenes or should i just change the translate? /Dennis

Share this post


Link to post
Share on other sites
Advertisement
#define BALL1 0
#define BALL2 1

void display()
{
if(ball1.status==BALL1)
ball1.bounce();
else
ball2.appear();

}

void Ball::bounce()
{
if(doneBouncing())
status=BALL2;
}

bool doneBouncing()
{
//time should be a variable holding amount of time u want it to appear
if(time>0)
{
//translate the ball here
time--;
}
}

Something like that. basically you should have a state variable to keep track of whats going on. And you dont need to translate away your ball once it is done. You can simply not render it.

Share this post


Link to post
Share on other sites
Aye, a state manager of a type would do you wonders...

~pseudo code~

class state{
scene();
}

class statemanager {
initialize()
update()
changestate(state)
int curent_time;
state curent_state;
}

initialize(){
set first state;
}

changestate(){
curent_state = ''
}

update(){
if((time = gettime()) != END_OF_SCENE_TIME){
state.scene.render();
}
else{
changestate(next state);
}

~end pseudo code~

of course, the state and scene details are specific to your app.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!