Hi there,
I've just learnt how to animate sprite using love.graphics.newQuad(),
I've also read how to use a loop to animate sprites,
the example is:
for i=1,8 do
love.graphics.newQuad((i-1)*32, 0, 32, 32, 256, 32)
end
What does i=1,8 mean?
Thank you
Using Loop to animate Sprites
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Using Loop to animate Sprites
Whenever I have a question about Lua, I visit these sites (the links take you to the relevent section on for loops):sabino wrote:What does i=1,8 mean?
- The lua-users wiki (usually the most helpful, has various tips and tricks).
The Lua Reference Manual (mostly useful if you just need a reminder or an exact technical explanation).
And Programming in Lua (probably the easiest for beginners, but I find the style difficult to read).
Re: Using Loop to animate Sprites
The easiest way to animate frames is.
Width, Height of the actual spritesheet.
Number of frames in the sprite sheet.
So say your walking "down" frames starts at frame 1 and goes to frame 5, you loop 1-5.
I swear there was documentation covering spritesheets...
Generally for loops work like this.
so say I'm checking to see if my party is less than three.
for i=1, RPG:Party<=3, i++
// Add people to meh party
end
else
print "Sorry, you have to many people in your party!"
end
Width, Height of the actual spritesheet.
Number of frames in the sprite sheet.
So say your walking "down" frames starts at frame 1 and goes to frame 5, you loop 1-5.
I swear there was documentation covering spritesheets...
Generally for loops work like this.
so say I'm checking to see if my party is less than three.
for i=1, RPG:Party<=3, i++
// Add people to meh party
end
else
print "Sorry, you have to many people in your party!"
end
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Using Loop to animate Sprites
I wrote about this in my love-tile-tutorial.
Start here:
https://github.com/kikito/love-tile-tut ... c-concepts
And keep reading until you reach a chapter called "0c loops". It's explained there.
Then you can keep reading to learn more stuff if you want.
Start here:
https://github.com/kikito/love-tile-tut ... c-concepts
And keep reading until you reach a chapter called "0c loops". It's explained there.
Then you can keep reading to learn more stuff if you want.
When I write def I mean function.
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 5 guests