Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I wanted my character's life to be the same as the other game state. My other game state is different the from my original state. I wanted to link my int to my new game state to make it the same. How do I link an integer?

share|improve this question
1  
Code sample? Give us something to work with, it'll help you get the answers you want. –  Byte56 Sep 26 '12 at 14:32
    
It sounds like what you're asking is essentially how to pass data between states. One way to solve this is to create a Player object containing the int that each state has a reference to. –  extropic-engine Oct 7 '12 at 20:32
add comment

closed as not a real question by Jari Komppa, Jonathan Hobbs, michael.bartnett, Byte56, Josh Petrie Oct 16 '12 at 16:05

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

2 Answers

If you're using FX you could try using a SimpleIntegerProperty and then bind that to another one. This will cause any change in one to reflect a change in the other. It works well for counting how many frames have been run in my game. My engine class has an int bound to an int in my ui class and it works well.

Does that sound like what you're trying to achieve?

share|improve this answer
add comment

You link to the other game state object, not to the integer directly. Then just return this.linkedState.health;

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.