Clothing, Hats and Weapons? Question about sprites showing equipment.
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Positive07
- Party member
- Posts: 1014
- Joined: Sun Aug 12, 2012 4:34 pm
- Location: Argentina
Re: Clothing, Hats and Weapons? Question about sprites showing equipment.
You need to research composite sprites, a combination between that and simple animations should do. You basically define actachment points for each sprite, then when you are gonna draw you check where each sprite should be drawn and compose the final sprite by drawing each sprite on top of each other.
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Clothing, Hats and Weapons? Question about sprites showing equipment.
You could also re-render Tiggy each time he changes its items (do not render "each possible item combination", just the current one). You will need to use a canvas to render that. You can use the canvas to render the animation with anim8 just fine. When there's an inventory change, swap the canvas for a different one and anim8 won't notice, if the frames are on the same positions.
When I write def I mean function.
Re: Clothing, Hats and Weapons? Question about sprites showing equipment.
here is a link with a little more information about it:
http://www.gamefromscratch.com/post/201 ... games.aspx
Hope it helps
http://www.gamefromscratch.com/post/201 ... games.aspx
Hope it helps
Re: Clothing, Hats and Weapons? Question about sprites showing equipment.
It depends on how much each item is going to change the animations of your character. For example if the items are weapons and the character holds each one differently and they make them move differently it's going to be more work. However if they only really change an image it's much easier. For example if the character wore a hat and they could get different hats that change the way it looked but they are worn the same way that is rather easy.
How that example could be implemented:
Changing 'currentHat' would change the hat the character is wearing. Hope this is helpful and I didn't miss the point.
How that example could be implemented:
Code: Select all
...
currentHat = 1
hats = {}
hats[1] = love.graphics.newImage("hat1.png")
hats[2] = love.graphics.newImage("hat2.png")
hats[3] = love.graphics.newImage("hat3.png")
hatOx = 10 -- hat offset on x axis ( how far along the character img the hat goes)
hatOy = 10 -- hat offset on y axis
...
function love.graphics.draw()
...
love.graphics.draw(playerImg, player.x, player.y)
love.graphics.draw(hats[currentHat], player.x + hatOx, player.y + hatOy)
...
end
Who is online
Users browsing this forum: Google [Bot], zorg and 74 guests