Tween trail problem

Hi! So i’m trying to make a sprite with simple tween animation…my code:

function setup()
    box = {x=100,y=100}

function draw()
    sprite("Cargo Bot:Command Grab", box.x,box.y)

function dotween()

The problem is it leaves a trail behind the sprite… What am I doing wrong wrong?

Two things:

  1. Not enclosing your code in tildes (~~~) on the forum, and
  2. Not using background() to clear the canvas at the start of draw.

So that’s what background does!

  1. I’ve wondered how to enclose code, but could not find it…it should be a sticky or in the sidebar since it’s so common a mistake…

Re code:

You can think of background as a flood fill. It’s also quite useful in setContext to blank the image to a given colour. The advantage of background over a large rect is that background(0,0,0,0) (note the alpha) sets every pixel to transparent black, where as the corresponding rect call does nothing due to the alpha.

(One could simulate background using rect with the right blendMode, though.)