so each Sprite object will have an image a sw and a sh
Eventually we'll calculate their values depending on what frame we want to display.
For now we'll set them both to 0
We'll set the imageData to trainerImg, and the sourceWidth and sourceHeight to 64
And we pass the player's x, y, width (64), and height (64) to the function
frameCount % 4
(this video is slowed down so we can read it better)
Add this if-statement around the code the increases frame by 1
By default the animation speed will be 0 (assuming most images will have no animation)
(preload waits for all images to load before starting the program)
The sprite will draw itself at the flower's x and y position, with a width and height of 32
Created 5 months ago
Teach coding to your students with MVCode Teach
MVCode offers an integrated product designed to teach coding to students.
Learn more about MVCode Teach