So I’m working on a 2D game and I want dust clouds to show behind the main character as he moves (think Enter the Gungeon). I have something in place now, but it isn’t quite right yet.
The problem I’m having is that it makes sense that the function should be called when you press a button to move the character, but I want the dust to dissipate even after the button is no longer pressed. The way it is now, when you stop pressing the button, it stops drawing the dust entirely.
Does anyone have any basic logic suggestions to fix this?
So this is always drawing from the table, assuming there’s something in it. Then my button presses can generate the table rows. Sounds easy enough.
What’s funny is I made something very similar that displays messages in a feed that slowly become more transparent as time goes on and I never realized how similar this was to that
derp
@n0ogit I don’t know how you’re doing your character or dust cloud, but I’ll just use basic Codea sprites for this example. Not sure if this is what you’re after, but just tap the screen to start the example.
displayMode(FULLSCREEN)
function setup()
dTab={}
cnt=0
pos=0
end
function draw()
background(40, 40, 50)
text("tap screen to start",WIDTH/2,HEIGHT-50)
for z=#dTab,1,-1 do
sprite("Small World:Dirt Patch",dTab[z].x,HEIGHT/2,dTab[z].y)
dTab[z].y=dTab[z].y-.5
if dTab[z].y==0 then
table.remove(dTab,z)
end
end
if pos>0 then
pos=pos-1
sprite("Platformer Art:Monster Moving",pos,HEIGHT/2)
if pos%50==0 then
table.insert(dTab,vec2(pos,120))
end
end
end
function touched(t)
if t.state==BEGAN then
dTab={}
pos=WIDTH
end
end