Hello everybody,
If I want to produce the game that the enemy will attack the player randomly by calling the random integer (randInt) and when the enemy attack the player it will play an animation, that means:
eg)
if (randInt == 0) {
// enemy plays defense animation
}
if (randInt == 1) {
//enemy plays attack animation
}
And in the paint method, I use clipping for the animation.
In the while loop (i.e game loop), when the Thread sleep 100ms, the clipping will change one frame (i.e:repaint), the animation will be fully played until the 6th frame is displayed. However, the problem is after 100 ms, the random and animation will begin at the same time, that means when the attack animation is playing, it will suddenly change to defense animation in the middle of the attack animation and vice versa.
So, can anyone can teach me where the random method should be placed so that it can fix this problem? ??? ???
Thanks for your reply~~