Slick Forums

Discuss the Slick 2D Library
It is currently Tue Oct 15, 2019 1:52 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sat May 07, 2011 5:46 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
Using game states you can sometimes see that render() is called on the state before enter() is. This seems counter-intuitive, however it's due to allowing transitions to have the greatest flexibility possible.

Fade transitions for instance call render() on the state that is being transitioned to before enter() since they need to have the state drawn before they draw the fade in colour across the top.

If you're finding render() fails because you initialised something in the enter() method that hasn't been called yet the suggestion is:

* Null check things to be initialized
* Have a flag indicating when the state has been entered and check that.

Kev


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 15, 2011 8:04 pm 
Offline
Oldbie
User avatar

Joined: Thu Jan 13, 2011 4:42 pm
Posts: 349
Thanks. That I was wondering why that was happening, and I didn't want to insert null checks until I knew what was going on.


Top
 Profile  
 
PostPosted: Thu Mar 21, 2013 6:51 pm 
Offline

Joined: Wed Nov 28, 2012 1:05 am
Posts: 30
kevglass wrote:
Using game states you can sometimes see that render() is called on the state before enter() is. This seems counter-intuitive, however it's due to allowing transitions to have the greatest flexibility possible.

Fade transitions for instance call render() on the state that is being transitioned to before enter() since they need to have the state drawn before they draw the fade in colour across the top.

If you're finding render() fails because you initialised something in the enter() method that hasn't been called yet the suggestion is:

* Null check things to be initialized
* Have a flag indicating when the state has been entered and check that.

Kev


It's called multi-threading.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot], MSN [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group