Sprites
Mithat Konar
February 29, 2016
Sprites
Download starter project
Basic template
- A minimal template for an enchant.js game.
- You won’t see anything when you run this because there’s nothing in the game yet.
Sprite creation
Adding a sprite to the canvas
- Create a new sprite, associate it with an image, and add it to the root scene.
Moving sprites
Moving the sprite a little each frame
- Frame-based animation, events, and event listeners.
Stop at the edge
- Check the location every frame.
Bouncing off an edge
- Add a variable to keep track of the direction.
Bouncing off both edges
- Repeat the right edge bounce logic for the left edge.
Bouncing off both edges (improved)
- Rethink the logic a little.