leaving a trail with transition.to

I’d like to move an object from one point to another, but leave the trail behind of each frame that is drawn. Is there some parameter to transition.to() that I could use to do this? I havent seen anything in the docs. Perhaps it has something to do with easing?
local l = display.newCircle(x1,y1,r)
l:setFillColor(255,0,0,255)
transition.to(l, {time=1000, alpha=255, x=x2, y=y2})
Thanks for any help.
[import]uid: 9562 topic_id: 3330 reply_id: 303330[/import]

not specifically at the moment. what you want to do is have a pool of sprites that follow the position of the object over time but fade out over time

if you can’t code it yourself then you might want to invest in this when it comes out
http://www.x-pressive.com

or have a look at some Flash tutorials and go from there…
http://active.tutsplus.com/tutorials/effects/create-a-glowing-mouse-trailer-in-flash/

maybe i’ll get chance to give it a go this weekend [import]uid: 6645 topic_id: 3330 reply_id: 9979[/import]

thanks jmp909.

hey, so I was just trying to do something similar programmatically and I came across this in the docs:
“To create such animations, you need to change the contents of the screen over time. In some environments, it’s natural to do this by changing properties of an object in loops such as a for or while loop. However, in Corona, you cannot produce animations using such loops because the screen is never updated within a block of code (see Screen Updates).”
http://developer.anscamobile.com/content/animation
However, this doesnt seem to be true. It seems to do updates all the time. Do you agree jmp909?

  
function drawStroke(x1, y1, x2, y2)  
-- note: the math is not quite right ;)  
 local m = (x2 - x1) / (y2 - y1)  
 local b = - (m \* x1 - y1)  
 local dx = 2  
  
 if (x1 \> x2) then  
 dx = -dx  
 end  
  
 local x = math.floor(x1 + dx)  
 local y = math.floor(m \* x + b)  
  
 while (x \< x2) do  
 print(string.format("x: %s, y: %s, m: %s, b: %s, dx: %s, x1: %s, y1: %s, x2: %s, y2: %s, radius: %s",x,y,math.fl  
 local l = display.newCircle(x, y, radius)  
 l:setFillColor(255,0,0,255)  
 x = math.floor(x + dx)  
 y = math.floor(m \* x + b)  
 end  
  
end  

[import]uid: 9562 topic_id: 3330 reply_id: 9980[/import]

ooh I get it…so since I want it draw immediately I’m ok… I see. now I just need to get the math just right. :>

I can draw in either x direction now…but I think my calculation of y is no accurate enough or something

[code]
local done = function(a, a2)
local done = false
if (dx > 0 and a < a2) then
done = true
end

if (dx < 0 and a > a2) then
done = true
end
return done
end

while (done(x,x2)) do

[/code] [import]uid: 9562 topic_id: 3330 reply_id: 9986[/import]

it means your movements are not shown until the end of your block of code. so you essentially need to do one animation step per frame. Whereas something like GLBasic does the animation screen updates within the loop.

eg

GLBasic:

FOR i=0 TO 10 STEP 2  
mySprite.x = mySprite.x+1  
SHOWSCREEN  
NEXT  

you are likely doing it right already [import]uid: 6645 topic_id: 3330 reply_id: 9984[/import]

jmp909- after thinking about your comment about updates not happening until after a code block- I have a question. If the updates are not happening until after my while loop, then why is it drawing the object at every interval. Wouldnt it just draw the final coords in the while loop?

To anyone else who stumbles across this post later: first, I have the formula for slope inverted above. ;> Second, see this: http://en.wikipedia.org/wiki/Bresenham’s_line_algorithm

[import]uid: 9562 topic_id: 3330 reply_id: 10008[/import]

Whatever you do, the screen only gets updated after all events in this frame are finished.

To create a trail… create a display object at the current postion of your emitting object and let it fade out via a transition.to staement which has an onComplege handler function that will remove the object when the transition is done. [import]uid: 5712 topic_id: 3330 reply_id: 10016[/import]

Hi jmp909,
In GLBasic, isn’t SHOWSCREEN equivalent of calling the Draw method everytime and storing all visible atrifacts on screen?

I guess working on the OpenGL principles, every frame has to be drawn every so many times per second. The offscreen buffer does some good stuff.

The major peeve is still that it does not retain what’s already there on screen. If there was a SAVESCREEN and then draw over it, that would be really nice.

cheers,

Jayant C Varma [import]uid: 3826 topic_id: 3330 reply_id: 10078[/import]