Slick Forums

Discuss the Slick 2D Library
It is currently Sun Oct 20, 2019 9:59 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sat Jan 18, 2014 9:54 am 
Offline

Joined: Fri Nov 08, 2013 8:58 am
Posts: 2
Hi,

I'm having trouble implementing an enum state machine within the gamestate class of my game here.

Before anyone goes ripping my head off, the reason why I'm nesting a state machine into the gamestate is so that I can handle turns (phases) within my game loop without having to create new state classes in slick.

I'm trying to implement the enums in such a way that they act as switches - only allowing certain code to run depending on the state of the machine - so far I think the only way to do this is to have a turnstate enum and a turn handler class and then implement the "switches" as objects within the update section of the game. However this is really not working out for me.

In my frustration I actually deleted my code so I have nothing to post - has anyone managed this and if so, could you post me an example to work from?

Relaxis


Top
 Profile  
 
PostPosted: Thu Jan 23, 2014 2:34 am 
Offline

Joined: Mon Dec 16, 2013 3:00 am
Posts: 22
This might be a silly question, but have you considered using the 'switch' statement in java; it allows you to use enums to switch on.
If you don't know: http://docs.oracle.com/javase/tutorial/java/nutsandbolts/switch.html

I hope this helps some!
Allen


Top
 Profile  
 
PostPosted: Mon Feb 13, 2017 10:33 am 
Offline

Joined: Mon Feb 13, 2017 10:32 am
Posts: 1
Check this one to know more about...Java Enum

Anto


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 126 guests


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