It looks like you're new here. If you want to get involved, click one of these buttons!
Hi! So i'm trying to make a sprite with simple tween animation...my code:
function setup()
box = {x=100,y=100}
dotween()
end
function draw()
sprite("Cargo Bot:Command Grab", box.x,box.y)
end
function dotween()
td=tween(2,box,{x=300,y=300})
tween.sequence(td)
end
The problem is it leaves a trail behind the sprite... What am I doing wrong wrong?
Comments
Two things:
~~~
) on the forum, andbackground()
to clear the canvas at the start ofdraw
.So that's what background does!
Re code: http://www.twolivesleft.com/Codea/Talk/discussion/275/faq-please-read
You can think of
background
as a flood fill. It's also quite useful insetContext
to blank the image to a given colour. The advantage ofbackground
over a largerect
is thatbackground(0,0,0,0)
(note the alpha) sets every pixel to transparent black, where as the correspondingrect
call does nothing due to the alpha.(One could simulate
background
usingrect
with the rightblendMode
, though.)