Project 4 - Animation Logic
Last updated
Was this helpful?
Last updated
Was this helpful?
Project 4 - Animation
The example programs below give simplified examples of animation that is controlled using an animation state
variable and an animation position
variable to control the animation.
In the example project below, a rotate animation is controlled by a State Variable: rotateState
which can be in one of 3 possible states: "UP", "DOWN", or "STOP".
This rotateState variable provides logic to control the animation using a structure.
Example Khan Academy Programs:
Rotate Animation:
Animation state variable: rotateState: can be in one of 3 possible animation states: "UP", "DOWN", or "STOP"
Animations position variable: angle.
When in "UP" state, angle is incremented: angle++
When in "DOWN" state, angle is decremented: angle--
angle
is restricted to range of values between minAngle and maxAngle.
Animation events:
When the angle >= maxAngle
, then the animation state: rotateState is set to: "DOWN"
When angle <= minAngle
, then animation state: rotateState is set to: "UP"
When the count variable equals maxCount, rotateState is set to: "STOP" to stop the animation.
Animation of line and offset rectangle