So I have my code here:
http://codepad.org/fIKaTf5P
Say I wanted to animate the second and third sprites in the following image:
How would I go about doing that?
Thanks in advance!
Animate images?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Re: Animate images?
You could write some code which watches the time and switches quads appropriately. But it's already been done for you - most lovers enjoy AnAL.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Re: Animate images?
You can create a variable like "current_sprite" and change it from walking to jumping as you need.
on love.load()
on love.update()
on love.draw()
As Taehl said, for walking you can use timers. But I prefer having a "player.walked" meter what changes the sprite along some distance and then resets the counter when the cycle ends.
Anyway, I have tried your code and it's great. The player has a very smooth movement, I liked it a lot, congratulations
on love.load()
Code: Select all
player.current_sprite = player.standing
Code: Select all
if player.y_velocity ~= 0 then
player.current_sprite = player.walking
...
else
player.current_sprite = player.standing
Code: Select all
love.graphics.drawq(player.sprite, player.current_sprite, player.x, player.y)
Anyway, I have tried your code and it's great. The player has a very smooth movement, I liked it a lot, congratulations
Re: Animate images?
Thanks to you both! I'll try AnAL. (Sounds so wrong, I love it!)
Re: Animate images?
As already mentioned, there are plenty of different ways to do it. If you're a beginner, I'd recommend doing something simple by yourself just for the practise. It's really not that hard.
My game called Hat Cat and the Obvious Crimes Against the Fundamental Laws of Physics is out now!
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest