Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Tween trail problem

edited March 2013 in General Posts: 43

Hi! So i'm trying to make a sprite with simple tween 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?



  • Posts: 2,161

    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 should be a sticky or in the sidebar since it's so common a mistake...
  • Posts: 2,161

    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.)

Sign In or Register to comment.