multiple transition on the same time

hi,

I would have multiple transition on the same time so i use a table view but the problem is that this animation is not callable at 100%… i don’t find the solution to have a snippet that works. There is always a little bug where all the star are displayed on the screen i have put a video to show that. Thanks if you could help me.

https://youtu.be/nRBAkWRmFUI

local Backgroundinvisible = display.newImageRect("back01.png", display.actualContentWidth,display.actualContentHeight) Backgroundinvisible.myId = 200 Backgroundinvisible.x, Backgroundinvisible.y= display.actualContentWidth\*.5,display.actualContentHeight\*.5 Backgroundinvisible.alpha = 1 local mathr = math.random -------------------------------------------------------------------------------------------------------------------------------- --                    NECESSARY -------------------------------------------------------------------------------------------------------------------------------- local numberofstarAnim = 3 local numberofstar = 300 local refX, refY = 200,200 local flag = true   --                    STAR EXPLODE local star = {} for a=1,numberofstar do star[a] = display.newImageRect( "star.png",40,40 )   for i=1, numberofstar do star[a].x=mathr(100,300) star[a].y=mathr(100,300) end   star[a].alpha = 0 --.5 star[a].xScale=1 star[a].yScale = 1 star[a].flag = true end --for   local function starExplode() -- a= var if flag then     flag=false print("starexplode") local countStarExplode = 0--test starExplode for b = 1, #star do if (star[b].flag == true ) then--conditions pour filtrer countStarExplode = countStarExplode + 1 if countStarExplode == numberofstarAnim then flag=true for a=1, b do     star[a].flag = false   local function beginAnimStar() star[a].alpha = 1 --.5 end --beginAnimStar   local function returnFlagToStar()     print("returnFlagToStar")     if star[a].flag == false  then star[a].flag = true end end   local function finishTheTransition() star[a].transition=transition.to(star[a],{time=500,alpha =0}) end--finishtheTransition     beginAnimStar() timer.performWithDelay(501, finishTheTransition) print("end") end end--if end--if end--for end--if end--function   --                    LISTENER ----------------------------------------------------- local function tapOnBackground(event) --touchk     if event.phase == "ended" then         target = event.target         if target.myId == 200  then                     print "touch"     starExplode()     end --if     end --if return true end   Backgroundinvisible:addEventListener("touch", tapOnBackground)

hi, the problem is in fact very simple. if i do

circle[1].transition=transition.to(circle[1], {time=500, x=200, y=500, alpha=1}) circle[2].transition=transition.to(circle[2], {time=500, x=150, y=400, alpha=1}) circle[3].transition=transition.to(circle[3], {time=499, x=120, y=150, alpha=1})

no problem, the transitions is ok. But when i would use a function and determinate the number of the next circle 3 (the number 4,7,10,…) by these example :

local Backgroundinvisible = display.newRect( 800,800,display.actualContentWidth,display.actualContentHeight) Backgroundinvisible.myId = 200 Backgroundinvisible.x, Backgroundinvisible.y= display.actualContentWidth\*.5,display.actualContentHeight\*.5 Backgroundinvisible.alpha = 0.1 local numberCircle = 30 local flag= true local circle = {} for i=1, numberCircle do circle[i]= display.newCircle(100,100,10) circle[i].x=200 circle[i].y=200 circle[i].flag= false end circle[1].flag=true circle[4].flag=true circle[7].flag=true circle[10].flag=true circle[13].flag=true circle[16].flag=true circle[19].flag=true circle[22].flag=true local function MovetheCircles() if flag then flag=false local count = 0 for i = 1, #circle do if (circle[i].flag == true ) then--conditions pour filtrer count = count + 1 if count == 1 then circle[i].flag = false for a=1, i do print(i) circle[i].flag = false w=i end a=w b=w+1 c=w+2 local function returnTheFlag1() circle[a].flag=false circle[a]:translate(200,200) circle[a].alpha=1 end local function returnTheFlag2() circle[b].flag=false circle[b]:translate(200,200) circle[b].alpha=1 end local function returnTheFlag3() print("return3") circle[c].flag=false circle[c]:translate(200,200) print("return3") circle[c].alpha=1 end local function transitionToCircle() if flag== false then print(a,b,c) circle[a].transition=transition.to(circle[a], {time=500, x=200, y=500, alpha=1, onComplete=returnTheFlag1}) circle[b].transition=transition.to(circle[b], {time=500, x=150, y=400, alpha=1,onComplete=returnTheFlag2}) circle[c].transition=transition.to(circle[c], {time=499, x=120, y=150, alpha=1,onComplete=returnTheFlag3}) end end transitionToCircle() end end end end end local function tapOnBackground(event) --touchk if event.phase == "ended" then target = event.target if target.myId == 200 then MovetheCircles() end end return true end Backgroundinvisible:addEventListener("touch", tapOnBackground)

all the transition are in the same moment so i have transition who are not completely finish.

my question is how to do this, to have transitions callable all the time ?

thanks for your help…

I galley a little to find the solution and the net does not give me anything about it.

could somenone explain to me why it doesn’t work ? i have specified my snippet and despite all my protections with specific flags interfered my transitions are compared to each other . Below is a video of the disaster : the behaviour expected ar that the circles returns to the center after the transition, it’s not the case

https://youtu.be/KHRIm158-qE

----------------------------------------------------------------------------------------- -- main.lua local Backgroundinvisible = display.newRect( 800,800,display.actualContentWidth,display.actualContentHeight) Backgroundinvisible.myId = 200 Backgroundinvisible.x, Backgroundinvisible.y= display.actualContentWidth\*.5,display.actualContentHeight\*.5 Backgroundinvisible.alpha = 0.1 local numberCircle = 30 local flag= true local circle = {} for i=1, numberCircle do circle[i]= display.newCircle(100,100,10) circle[i].x=200 circle[i].y=200 circle[i].flag= true circle[i].trans= true end local function MovetheCircles() local count = 0 for i = 1, #circle do if (circle[i].flag == true ) then--conditions pour filtrer count = count + 1 if count == 1 then for a=1, i do circle[i].flag = false w=i end a=w b=w+1 c=w+2 local function returnTheFlag1() if circle[a].trans == false then circle[a].flag=false circle[a]:translate(200,200) circle[a].alpha=1 circle[a].trans =true end end local function returnTheFlag2() if circle[b].trans == false then circle[b].flag=false circle[b]:translate(200,200) circle[b].alpha=1 circle[b].trans =true end end local function returnTheFlag3() if circle[c].trans == false then circle[c].flag=false circle[c]:translate(200,200) circle[c].alpha=1 circle[c].trans =true end end local function transitionToCircle() if circle[a].trans then circle[a].trans = false print(circle[a].trans) circle[a].transition=transition.to(circle[a], {time=500, x=200, y=500, alpha=1, onComplete=returnTheFlag1}) end if circle[b].trans then circle[b].trans = false circle[b].transition=transition.to(circle[b], {time=500, x=150, y=400, alpha=1,onComplete=returnTheFlag2}) end if circle[c].trans then circle[c].trans = false circle[c].transition=transition.to(circle[c], {time=499, x=120, y=150, alpha=1,onComplete=returnTheFlag3}) end end transitionToCircle() end --for end --if end--for end local function tapOnBackground(event) --touchk if event.phase == "ended" then target = event.target if target.myId == 200 then MovetheCircles() end --if end --if return true end Backgroundinvisible:addEventListener("touch", tapOnBackground)

I can only guess here, that you are trying to return each ‘circle[a], circle[b], circle[c]’ to the position 200,200 on the screen. Is that correct?

If so, translate(200,200) will not do that.

In your case the circles are going to return to :

circle[a]  x = 400   y  = 900

circle[b] x = 350    y = 600

circle[c] x = 320    y = 350

In those ‘returnTheFlag’ functions that you have for each of the 3 circles, try to do a ‘transition.to’ instead  of the ‘translate’.  Maybe something like this:

transition.to(circle[a],  {time = 500, x = 200, y = 200 }) 

I am not real clear on what you are trying to do. But I think that might answer your question.

Good luck.

hi, 

you are right about the translate but it’s the same. When i clic my transition are stopped and does not continue to the end. 

what I’m trying to do is generate objects following one another when I click and can be reused indefinitely.

I am still not completely clear on what exactly you are trying to do. But here is some code (very quickly put together) that hopefully will point you in the right direction to solving your problem.  

Good luck.

local points = { {x = 200, y = 500}, {x = 150, y = 400}, {x = 120, y = 150} } local circle = {} for i = 1, 30 do table.insert(circle, display.newCircle(200,200,10)) end local count = 1 local pointCnt = 1 local function returnTheCircle(obj) transition.to(obj, {time=500, x=200, y=200, alpha=1}) end local function onTouchSingle(e) if e.phase == "ended" then transition.to(circle[count], {time=500, x=points[pointCnt].x, y=points[pointCnt].y, alpha=1, onComplete=returnTheCircle}) pointCnt = pointCnt + 1 if pointCnt \> #points then pointCnt = 1 end count = count + 1 if count \> #circle then count = 1 end end end local function onTouchMulti(e) if e.phase == "ended" then transition.to(circle[count], {time=500, x = 200, y = 500, alpha=1, onComplete=returnTheCircle}) count = count + 1 transition.to(circle[count], {time=500, x = 150, y = 400, alpha=1, onComplete=returnTheCircle}) count = count + 1 transition.to(circle[count], {time=500, x = 120, y = 150, alpha=1, onComplete=returnTheCircle}) count = count + 1 if count \> #circle then count = 1 end end end local trigger1 = display.newRect(150,100, 50, 50) trigger1:addEventListener("touch", onTouchSingle) local trigger2 = display.newRect(300,100, 50, 50) trigger2:addEventListener("touch", onTouchMulti)

This might be more what you are trying to do. All 3 of these example do what (I think) you said you are trying to do:

‘generate objects that follow one another and can be reused indefinitely.’

You have alpha of the circles set to ‘1’ in all the transition code of your last example, so I am not sure where you want or plan to reduce the alpha> I am assuming you are wanting to do that. So I guessed, to reduce the alpha when firing from the base and back to full alpha when returned to base.  You of course can play around with where and how much you want to change the alpha. 

You might learn a bit by playing around with one of the particle engines you can find on the forum. It takes time, but you can learn alot, and be able to generate even better effects.

local function resetCircles() for i = 1, #circle do transition.to(circle[i], {delay = (i \* 100), time=500, x = 200, y = 200, alpha=1}) end end local function onTouch(e) if e.phase == "ended" then for i = 1, #circle do transition.to(circle[i], {delay = (i \* 100), time=500, x = 200, y = 500, alpha=0}) end timer.performWithDelay(2000, resetCircles) end end local trigger3 = display.newRect(400,100, 50, 50) trigger3:addEventListener("touch", onTouch)

Hi.  I saw your cross-link to this post and I’d like to help, but I’m afraid I’m confused about what you are trying to achieve.  

Can you provide a ‘terse’ description using a bullet list of steps describing what you want to do?

ex:

I click a button and I want to my code to:

  • create three objects
  • move them from A to B
  • Circle 2 should follow circle 1
  • Circle 3 should follow circle 2

If I click again … something else should happen…

For now, I’ve guessed and made an example using SSK:

function public.run( group ) public.isRunning = true local physics = require("physics") physics.start() physics.setGravity(0,9.8) physics.setDrawMode( "hybrid" ) -- Localizations local newCircle = ssk.display.newCircle local newRect = ssk.display.newRect local newImageRect = ssk.display.newImageRect local easyIFC = ssk.easyIFC local mRand = math.random local angle2Vector = ssk.math2d.angle2Vector local vector2Angle = ssk.math2d.vector2Angle local scaleVec = ssk.math2d.scale local addVec = ssk.math2d.add local subVec = ssk.math2d.sub local getNormals = ssk.math2d.normals local lenVec = ssk.math2d.length local normVec = ssk.math2d.normalize -- Locals -- local moveSpeed = 200 local distanceBetweenCircles = 35 -- Background to catch touches -- local circles = {} local circleColors = { \_R\_, \_G\_, \_B\_, \_O\_, \_Y\_ } local circleRadius = { 18, 16, 10, 8, 6 } local x = centerX local y = centerY for i = 1, 5 do circles[i] = newCircle( group, x, y, { radius = circleRadius[i], fill = circleColors[i] } ) x = x - distanceBetweenCircles end -- Touch Listener (and mover) -- local function onTouch( self, event ) if( event.phase == "began" ) then -- Stop any current transitions -- for i = 1, #circles do transition.cancel( circles[i] ) end -- Calc distance First circle needs to move -- local tvec = { x = event.x, y = event.y } local vec = subVec( tvec, circles[1] ) local len = lenVec( vec ) local time = 1000 \* len / moveSpeed transition.to( circles[1], { x = tvec.x, y = tvec.y, time = time }) -- Calculate the distance and speed for the rest. -- for i = 2, #circles do -- Where to move to calc local vec2 = normVec( vec ) vec2 = scaleVec( vec2, (i-1) \* distanceBetweenCircles ) vec2 = addVec( tvec, vec2 ) -- Speed calc local vec3 = subVec( vec2, circles[i] ) local len = lenVec( vec3 ) local time = 1000 \* len / moveSpeed -- Move transition.to( circles[i], { x = vec2.x, y = vec2.y, time = time }) end end return true end local touchCatcher = newRect( group, centerX, centerY, { w = fullw, h = fullh, touch = onTouch, fill = \_DARKERGREY\_ } ) touchCatcher:toBack() end

It does this (probably not what you want):

https://www.youtube.com/watch?v=QG8kLujEB2o&feature=youtu.be

I think this is more like what you want?

https://www.youtube.com/watch?v=4uwOSwr_O9U&feature=youtu.be

function public.run( group ) public.isRunning = true local physics = require("physics") physics.start() physics.setGravity(0,9.8) physics.setDrawMode( "hybrid" ) -- Localizations local newCircle = ssk.display.newCircle local newRect = ssk.display.newRect local newImageRect = ssk.display.newImageRect local easyIFC = ssk.easyIFC local mRand = math.random local angle2Vector = ssk.math2d.angle2Vector local vector2Angle = ssk.math2d.vector2Angle local scaleVec = ssk.math2d.scale local addVec = ssk.math2d.add local subVec = ssk.math2d.sub local getNormals = ssk.math2d.normals local lenVec = ssk.math2d.length local normVec = ssk.math2d.normalize -- Locals -- local moveSpeed = 200 local circleColors = { \_R\_, \_G\_, \_B\_, \_O\_, \_Y\_ } local circleRadius = { 18, 16, 10, 8, 6 } -- Following listener -- local function onEnterFrame( self ) if( not public.isRunning ) then ignore( "enterFrame", self ) return end local myNum = self.myNum local prior = self.priorCircle local vec = subVec( prior, self ) vec = normVec( vec ) vec = scaleVec( vec, 2 \* circleRadius[myNum-1] + 2 ) self.x = prior.x + vec.x self.y = prior.y + vec.y end -- Background to catch touches -- local circles = {} local x = centerX local y = centerY for i = 1, 5 do if( i == 1 ) then circles[i] = newCircle( group, x, y, { radius = circleRadius[i], fill = circleColors[i] } ) else circles[i] = newCircle( group, x, y, { radius = circleRadius[i], fill = circleColors[i], myNum = i, priorCircle = circles[i-1], enterFrame = onEnterFrame } ) end x = x - 2 \* circleRadius[i] + 2 end -- Touch Listener (and mover) -- local function onTouch( self, event ) if( event.phase == "began" ) then -- Stop any current transitions -- for i = 1, #circles do transition.cancel( circles[i] ) end -- Calc distance First circle needs to move -- local tvec = { x = event.x, y = event.y } local vec = subVec( tvec, circles[1] ) local len = lenVec( vec ) local time = 1000 \* len / moveSpeed transition.to( circles[1], { x = tvec.x, y = tvec.y, time = time }) end return true end local touchCatcher = newRect( group, centerX, centerY, { w = fullw, h = fullh, touch = onTouch, fill = \_DARKERGREY\_ } ) touchCatcher:toBack() end

Hello to you both and thank you a lot :slight_smile:

Cyberparkstudio by your snippet i have understood what’s wrong in my snippet.

You might learn a bit by playing around with one of the particle engines you can find on the forum. It takes time, but you can learn alot, and be able to generate even better effects.

I’ve wanted to learn the particles , much used cbeffects but we do not find a lot of tutorial about it and it has to look pretty hard …
Roaming Gamer you developped an engine of particles , this requires a lot of learning ? have you good tuto to educate ?

hi, the problem is in fact very simple. if i do

circle[1].transition=transition.to(circle[1], {time=500, x=200, y=500, alpha=1}) circle[2].transition=transition.to(circle[2], {time=500, x=150, y=400, alpha=1}) circle[3].transition=transition.to(circle[3], {time=499, x=120, y=150, alpha=1})

no problem, the transitions is ok. But when i would use a function and determinate the number of the next circle 3 (the number 4,7,10,…) by these example :

local Backgroundinvisible = display.newRect( 800,800,display.actualContentWidth,display.actualContentHeight) Backgroundinvisible.myId = 200 Backgroundinvisible.x, Backgroundinvisible.y= display.actualContentWidth\*.5,display.actualContentHeight\*.5 Backgroundinvisible.alpha = 0.1 local numberCircle = 30 local flag= true local circle = {} for i=1, numberCircle do circle[i]= display.newCircle(100,100,10) circle[i].x=200 circle[i].y=200 circle[i].flag= false end circle[1].flag=true circle[4].flag=true circle[7].flag=true circle[10].flag=true circle[13].flag=true circle[16].flag=true circle[19].flag=true circle[22].flag=true local function MovetheCircles() if flag then flag=false local count = 0 for i = 1, #circle do if (circle[i].flag == true ) then--conditions pour filtrer count = count + 1 if count == 1 then circle[i].flag = false for a=1, i do print(i) circle[i].flag = false w=i end a=w b=w+1 c=w+2 local function returnTheFlag1() circle[a].flag=false circle[a]:translate(200,200) circle[a].alpha=1 end local function returnTheFlag2() circle[b].flag=false circle[b]:translate(200,200) circle[b].alpha=1 end local function returnTheFlag3() print("return3") circle[c].flag=false circle[c]:translate(200,200) print("return3") circle[c].alpha=1 end local function transitionToCircle() if flag== false then print(a,b,c) circle[a].transition=transition.to(circle[a], {time=500, x=200, y=500, alpha=1, onComplete=returnTheFlag1}) circle[b].transition=transition.to(circle[b], {time=500, x=150, y=400, alpha=1,onComplete=returnTheFlag2}) circle[c].transition=transition.to(circle[c], {time=499, x=120, y=150, alpha=1,onComplete=returnTheFlag3}) end end transitionToCircle() end end end end end local function tapOnBackground(event) --touchk if event.phase == "ended" then target = event.target if target.myId == 200 then MovetheCircles() end end return true end Backgroundinvisible:addEventListener("touch", tapOnBackground)

all the transition are in the same moment so i have transition who are not completely finish.

my question is how to do this, to have transitions callable all the time ?

thanks for your help…

I galley a little to find the solution and the net does not give me anything about it.

could somenone explain to me why it doesn’t work ? i have specified my snippet and despite all my protections with specific flags interfered my transitions are compared to each other . Below is a video of the disaster : the behaviour expected ar that the circles returns to the center after the transition, it’s not the case

https://youtu.be/KHRIm158-qE

----------------------------------------------------------------------------------------- -- main.lua local Backgroundinvisible = display.newRect( 800,800,display.actualContentWidth,display.actualContentHeight) Backgroundinvisible.myId = 200 Backgroundinvisible.x, Backgroundinvisible.y= display.actualContentWidth\*.5,display.actualContentHeight\*.5 Backgroundinvisible.alpha = 0.1 local numberCircle = 30 local flag= true local circle = {} for i=1, numberCircle do circle[i]= display.newCircle(100,100,10) circle[i].x=200 circle[i].y=200 circle[i].flag= true circle[i].trans= true end local function MovetheCircles() local count = 0 for i = 1, #circle do if (circle[i].flag == true ) then--conditions pour filtrer count = count + 1 if count == 1 then for a=1, i do circle[i].flag = false w=i end a=w b=w+1 c=w+2 local function returnTheFlag1() if circle[a].trans == false then circle[a].flag=false circle[a]:translate(200,200) circle[a].alpha=1 circle[a].trans =true end end local function returnTheFlag2() if circle[b].trans == false then circle[b].flag=false circle[b]:translate(200,200) circle[b].alpha=1 circle[b].trans =true end end local function returnTheFlag3() if circle[c].trans == false then circle[c].flag=false circle[c]:translate(200,200) circle[c].alpha=1 circle[c].trans =true end end local function transitionToCircle() if circle[a].trans then circle[a].trans = false print(circle[a].trans) circle[a].transition=transition.to(circle[a], {time=500, x=200, y=500, alpha=1, onComplete=returnTheFlag1}) end if circle[b].trans then circle[b].trans = false circle[b].transition=transition.to(circle[b], {time=500, x=150, y=400, alpha=1,onComplete=returnTheFlag2}) end if circle[c].trans then circle[c].trans = false circle[c].transition=transition.to(circle[c], {time=499, x=120, y=150, alpha=1,onComplete=returnTheFlag3}) end end transitionToCircle() end --for end --if end--for end local function tapOnBackground(event) --touchk if event.phase == "ended" then target = event.target if target.myId == 200 then MovetheCircles() end --if end --if return true end Backgroundinvisible:addEventListener("touch", tapOnBackground)

I can only guess here, that you are trying to return each ‘circle[a], circle[b], circle[c]’ to the position 200,200 on the screen. Is that correct?

If so, translate(200,200) will not do that.

In your case the circles are going to return to :

circle[a]  x = 400   y  = 900

circle[b] x = 350    y = 600

circle[c] x = 320    y = 350

In those ‘returnTheFlag’ functions that you have for each of the 3 circles, try to do a ‘transition.to’ instead  of the ‘translate’.  Maybe something like this:

transition.to(circle[a],  {time = 500, x = 200, y = 200 }) 

I am not real clear on what you are trying to do. But I think that might answer your question.

Good luck.

hi, 

you are right about the translate but it’s the same. When i clic my transition are stopped and does not continue to the end. 

what I’m trying to do is generate objects following one another when I click and can be reused indefinitely.

I am still not completely clear on what exactly you are trying to do. But here is some code (very quickly put together) that hopefully will point you in the right direction to solving your problem.  

Good luck.

local points = { {x = 200, y = 500}, {x = 150, y = 400}, {x = 120, y = 150} } local circle = {} for i = 1, 30 do table.insert(circle, display.newCircle(200,200,10)) end local count = 1 local pointCnt = 1 local function returnTheCircle(obj) transition.to(obj, {time=500, x=200, y=200, alpha=1}) end local function onTouchSingle(e) if e.phase == "ended" then transition.to(circle[count], {time=500, x=points[pointCnt].x, y=points[pointCnt].y, alpha=1, onComplete=returnTheCircle}) pointCnt = pointCnt + 1 if pointCnt \> #points then pointCnt = 1 end count = count + 1 if count \> #circle then count = 1 end end end local function onTouchMulti(e) if e.phase == "ended" then transition.to(circle[count], {time=500, x = 200, y = 500, alpha=1, onComplete=returnTheCircle}) count = count + 1 transition.to(circle[count], {time=500, x = 150, y = 400, alpha=1, onComplete=returnTheCircle}) count = count + 1 transition.to(circle[count], {time=500, x = 120, y = 150, alpha=1, onComplete=returnTheCircle}) count = count + 1 if count \> #circle then count = 1 end end end local trigger1 = display.newRect(150,100, 50, 50) trigger1:addEventListener("touch", onTouchSingle) local trigger2 = display.newRect(300,100, 50, 50) trigger2:addEventListener("touch", onTouchMulti)

This might be more what you are trying to do. All 3 of these example do what (I think) you said you are trying to do:

‘generate objects that follow one another and can be reused indefinitely.’

You have alpha of the circles set to ‘1’ in all the transition code of your last example, so I am not sure where you want or plan to reduce the alpha> I am assuming you are wanting to do that. So I guessed, to reduce the alpha when firing from the base and back to full alpha when returned to base.  You of course can play around with where and how much you want to change the alpha. 

You might learn a bit by playing around with one of the particle engines you can find on the forum. It takes time, but you can learn alot, and be able to generate even better effects.

local function resetCircles() for i = 1, #circle do transition.to(circle[i], {delay = (i \* 100), time=500, x = 200, y = 200, alpha=1}) end end local function onTouch(e) if e.phase == "ended" then for i = 1, #circle do transition.to(circle[i], {delay = (i \* 100), time=500, x = 200, y = 500, alpha=0}) end timer.performWithDelay(2000, resetCircles) end end local trigger3 = display.newRect(400,100, 50, 50) trigger3:addEventListener("touch", onTouch)

Hi.  I saw your cross-link to this post and I’d like to help, but I’m afraid I’m confused about what you are trying to achieve.  

Can you provide a ‘terse’ description using a bullet list of steps describing what you want to do?

ex:

I click a button and I want to my code to:

  • create three objects
  • move them from A to B
  • Circle 2 should follow circle 1
  • Circle 3 should follow circle 2

If I click again … something else should happen…

For now, I’ve guessed and made an example using SSK:

function public.run( group ) public.isRunning = true local physics = require("physics") physics.start() physics.setGravity(0,9.8) physics.setDrawMode( "hybrid" ) -- Localizations local newCircle = ssk.display.newCircle local newRect = ssk.display.newRect local newImageRect = ssk.display.newImageRect local easyIFC = ssk.easyIFC local mRand = math.random local angle2Vector = ssk.math2d.angle2Vector local vector2Angle = ssk.math2d.vector2Angle local scaleVec = ssk.math2d.scale local addVec = ssk.math2d.add local subVec = ssk.math2d.sub local getNormals = ssk.math2d.normals local lenVec = ssk.math2d.length local normVec = ssk.math2d.normalize -- Locals -- local moveSpeed = 200 local distanceBetweenCircles = 35 -- Background to catch touches -- local circles = {} local circleColors = { \_R\_, \_G\_, \_B\_, \_O\_, \_Y\_ } local circleRadius = { 18, 16, 10, 8, 6 } local x = centerX local y = centerY for i = 1, 5 do circles[i] = newCircle( group, x, y, { radius = circleRadius[i], fill = circleColors[i] } ) x = x - distanceBetweenCircles end -- Touch Listener (and mover) -- local function onTouch( self, event ) if( event.phase == "began" ) then -- Stop any current transitions -- for i = 1, #circles do transition.cancel( circles[i] ) end -- Calc distance First circle needs to move -- local tvec = { x = event.x, y = event.y } local vec = subVec( tvec, circles[1] ) local len = lenVec( vec ) local time = 1000 \* len / moveSpeed transition.to( circles[1], { x = tvec.x, y = tvec.y, time = time }) -- Calculate the distance and speed for the rest. -- for i = 2, #circles do -- Where to move to calc local vec2 = normVec( vec ) vec2 = scaleVec( vec2, (i-1) \* distanceBetweenCircles ) vec2 = addVec( tvec, vec2 ) -- Speed calc local vec3 = subVec( vec2, circles[i] ) local len = lenVec( vec3 ) local time = 1000 \* len / moveSpeed -- Move transition.to( circles[i], { x = vec2.x, y = vec2.y, time = time }) end end return true end local touchCatcher = newRect( group, centerX, centerY, { w = fullw, h = fullh, touch = onTouch, fill = \_DARKERGREY\_ } ) touchCatcher:toBack() end

It does this (probably not what you want):

https://www.youtube.com/watch?v=QG8kLujEB2o&feature=youtu.be

I think this is more like what you want?

https://www.youtube.com/watch?v=4uwOSwr_O9U&feature=youtu.be

function public.run( group ) public.isRunning = true local physics = require("physics") physics.start() physics.setGravity(0,9.8) physics.setDrawMode( "hybrid" ) -- Localizations local newCircle = ssk.display.newCircle local newRect = ssk.display.newRect local newImageRect = ssk.display.newImageRect local easyIFC = ssk.easyIFC local mRand = math.random local angle2Vector = ssk.math2d.angle2Vector local vector2Angle = ssk.math2d.vector2Angle local scaleVec = ssk.math2d.scale local addVec = ssk.math2d.add local subVec = ssk.math2d.sub local getNormals = ssk.math2d.normals local lenVec = ssk.math2d.length local normVec = ssk.math2d.normalize -- Locals -- local moveSpeed = 200 local circleColors = { \_R\_, \_G\_, \_B\_, \_O\_, \_Y\_ } local circleRadius = { 18, 16, 10, 8, 6 } -- Following listener -- local function onEnterFrame( self ) if( not public.isRunning ) then ignore( "enterFrame", self ) return end local myNum = self.myNum local prior = self.priorCircle local vec = subVec( prior, self ) vec = normVec( vec ) vec = scaleVec( vec, 2 \* circleRadius[myNum-1] + 2 ) self.x = prior.x + vec.x self.y = prior.y + vec.y end -- Background to catch touches -- local circles = {} local x = centerX local y = centerY for i = 1, 5 do if( i == 1 ) then circles[i] = newCircle( group, x, y, { radius = circleRadius[i], fill = circleColors[i] } ) else circles[i] = newCircle( group, x, y, { radius = circleRadius[i], fill = circleColors[i], myNum = i, priorCircle = circles[i-1], enterFrame = onEnterFrame } ) end x = x - 2 \* circleRadius[i] + 2 end -- Touch Listener (and mover) -- local function onTouch( self, event ) if( event.phase == "began" ) then -- Stop any current transitions -- for i = 1, #circles do transition.cancel( circles[i] ) end -- Calc distance First circle needs to move -- local tvec = { x = event.x, y = event.y } local vec = subVec( tvec, circles[1] ) local len = lenVec( vec ) local time = 1000 \* len / moveSpeed transition.to( circles[1], { x = tvec.x, y = tvec.y, time = time }) end return true end local touchCatcher = newRect( group, centerX, centerY, { w = fullw, h = fullh, touch = onTouch, fill = \_DARKERGREY\_ } ) touchCatcher:toBack() end

Hello to you both and thank you a lot :slight_smile:

Cyberparkstudio by your snippet i have understood what’s wrong in my snippet.

You might learn a bit by playing around with one of the particle engines you can find on the forum. It takes time, but you can learn alot, and be able to generate even better effects.

I’ve wanted to learn the particles , much used cbeffects but we do not find a lot of tutorial about it and it has to look pretty hard …
Roaming Gamer you developped an engine of particles , this requires a lot of learning ? have you good tuto to educate ?