Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help,
read this .
sabino
Prole
Posts: 4 Joined: Thu Jun 19, 2014 4:10 pm
Post
by sabino » Tue Jul 01, 2014 4:16 pm
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
bdjnk
Citizen
Posts: 81 Joined: Wed Jul 03, 2013 11:44 pm
Post
by bdjnk » Tue Jul 01, 2014 4:45 pm
sabino wrote: What does i=1,8 mean?
Whenever I have a question about Lua, I visit these sites (the links take you to the relevent section on
for loops):
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).
Rukiri
Citizen
Posts: 68 Joined: Mon Jun 27, 2011 5:52 am
Post
by Rukiri » Tue Jul 01, 2014 4:53 pm
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
kikito
Inner party member
Posts: 3153 Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:
Post
by kikito » Tue Jul 01, 2014 5:21 pm
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.
When I write def I mean function .
Users browsing this forum: Bing [Bot] , cowardlycamper32 , Google [Bot] and 8 guests