|
|||
| week 13a - state management | |||
state management :
|
example code: stateMgt.dir In more complex applications, objects in the system need to keep track of their internal state and behave differently depending on that state. For example, in a car, different things work depending on the position of the key:
In software, taking care of these different states and corresponding behaviors is called "STATE MANGEMENT". It simply means that the software:
|
|
| state example 1 : | In this simple example, the sprite upper sprite object pays attention to where it is in the horizontal (.locH) dimension, and shows a different word and plays a different sound depending if it is in the left, middle or right hand side when the user clicks on it.
|
|
| state example 2 : | In this example, the state is managed within the sprite rather than by the sprite's position on the screen. Each time the user clicks, the sprite shows a word and plays a sound corresponding to its current state. It also advances itself to the next state with a user click. So each click causes the sprite to change from one state to the next. currentState = 1; |
| all materials on this web site © copyright 2004, Philip van Allen |
top |