How to group 130 png files to make an explosion?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Sir_Silver
- Party member
- Posts: 286
- Joined: Mon Aug 22, 2016 2:25 pm
- Contact:
Re: How to group 130 png files to make an explosion?
Pretty cool, not perfect like you said but you can always make it better. Like Ivan mentioned, using particles might be a better way of trying to do what you want. I haven't used particles yet, so I won't be of much help with that, but you probably will want to look into that on your own time.
- josefnpat
- Inner party member
- Posts: 955
- Joined: Wed Oct 05, 2011 1:36 am
- Location: your basement
- Contact:
Re: How to group 130 png files to make an explosion?
If you are looking for a tool to pack your sprites, check out urraka's texpack. Cannot plug this tool enough.
Missing Sentinel Software | Twitter
FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push
FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push
Re: How to group 130 png files to make an explosion?
i make a test for animate a sprite but i don't understand how slow down the animation :
Code: Select all
local animation_table = {}
local current_frame = 1
local current_frame_duration = 0.5
local time_per_frame = 0.1
function love.load()
love.graphics.setBackgroundColor(0, 20, 10)
image = love.graphics.newImage("perso.png") --We load the main image file that we want to animate.
local image_w, image_h = image:getDimensions()
local quad_w, quad_h = image_w / 5, image_h / 4
--[[
The width of our quad will be equal to the width of the image divided by how many frames there are horizontally.
The height of our quad is equal to the height of the image divded by the number of frames vertically.
]]
for y = 0, 10 do
for x = 0, 4 do
animation_table[#animation_table + 1] = love.graphics.newQuad(x * quad_w, y * quad_h, quad_w, quad_h, image_w, image_h)
end
end
--[[
This for loop allows us to offset subsections of our main image and store those subsections
into our animation table so that we can draw it.
]]
animation_table[#animation_table] = nil --The last image in the animation I've choosen is blank, so I remove it here.
end
function love.update(dt)
current_frame_duration = current_frame_duration + dt
if current_frame_duration >= time_per_frame then
current_frame = current_frame + 1
if current_frame > #animation_table then
current_frame = 1 --If we increment passed how many frames we have, we go back to the first frame.
end
end
end
function love.draw()
local x, y = love.mouse.getPosition()
love.graphics.draw(image, animation_table[current_frame], x, y)
--Here we draw the current frame, determined in love.update, at our mouse position
end
- Attachments
-
- sprite.love
- (106.86 KiB) Downloaded 229 times
- Positive07
- Party member
- Posts: 1014
- Joined: Sun Aug 12, 2012 4:34 pm
- Location: Argentina
Re: How to group 130 png files to make an explosion?
In order to slow it down to need to increment time_per_frame, it is the time that it takes to go from one frame to another, making it bigger will make it seem slower
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)
Re: How to group 130 png files to make an explosion?
To control time between sprite change I use:
In love.load I put:
check = setTimeDelay( 0.1 )
and in love.update:
if check( dt ) then (what ever you want updated) end
Code: Select all
function setTimeDelay( delay )
local lapsed = 0
return function( dt )
lapsed = lapsed < delay and lapsed + dt or 0
return lapsed == 0
end
end
check = setTimeDelay( 0.1 )
and in love.update:
if check( dt ) then (what ever you want updated) end
Who is online
Users browsing this forum: Google [Bot] and 9 guests