square transition problem

no error.

just the second transition and the local square2 which does not appear

try this:

 local function app() local square2=display display.newRect( 150, 100, 60, 60 ) local deplacement2=transition.to( square2, { time=200, x=200, y=100, yScale=0.5, xScale=0.5}) end local square = display.newRect( 100, 100, 30, 30 ) local function removeob(obj) obj:removeSelf() timer.performWithDelay(190, app) end local deplacement = transition.to( square, { time=200, x=150, y=100, yScale=2, xScale=2, onComplete=function() removeob(square) end} )

I tried your code but still the same concern.
I corrected the line with remove (obj) by remove (square)

 local function app()         local square2=display display.newRect( 150, 100, 60, 60 )         local deplacement2=transition.to( square2, { time=200, x=200, y=100, yScale=0.5, xScale=0.5})     end local square = display.newRect( 100, 100, 30, 30 ) local function removeob(square)     square:removeSelf()     timer.performWithDelay(190, app) end local deplacement = transition.to( square, { time=200, x=150, y=100, yScale=2, xScale=2, onComplete=function()     removeob(square) end} )

try print something inside the remove function to check whether the function runs correctly

local function removeob(square) square:removeSelf() print('call square 2') app() //try calling it without any timer end

it’s seems that the local square2 is not considered

result = nil

local function removeob(square)     square:removeSelf()     app()     print(square2) end

i have modified my code with but it’s the same

 local function app()         local square2=display display.newRect( 150, 100, 60, 60 )         local deplacement2=transition.to( square2, { time=200, x=200, y=100, yScale=0.5, xScale=0.5})         return square2, deplacement2     end

writing different and the problem is the local essai wich don’t work

 local square = display.newRect( 100, 100, 30, 30 )  local essai = function (square, square2, deplacement2)         square:removeSelf()         local square2=display display.newRect( 150, 100, 60, 60 )         local deplacement2=transition.to( square2, { time=200, x=200, y=100, yScale=0.5, xScale=0.5})     end local deplacement = transition.to( square, { time=200, x=150, y=100, yScale=2, xScale=2, onComplete=essai})

In your app function you have display written twice…the code posted by Jonathan should work with that error corrected.

[lua]

local function app()

      local square2 = display.newRect( 150 , 100 , 60 , 60 )

local deplacement2=transition.to( square2, { time= 200 , x= 200 , y= 100 , yScale= 0.5 , xScale= 0.5 })

end

local square = display.newRect( 100 , 100 , 30 , 30 )

local function removeob(obj)

    obj:removeSelf()

    timer.performWithDelay( 190 , app)

end

local deplacement = transition.to( square, { time= 200 , x= 150 , y= 100 , yScale= 2 , xScale= 2 , onComplete=function()

    removeob(square)

end} )

[/lua]

thanks nick sherman

the code I wrote earlier works now

thank you both

 local square = display.newRect( 100, 100, 30, 30 )  local function essai(square)         square:removeSelf()         local square2=display.newRect( 150, 100, 60, 60 )         local deplacement2=transition.to( square2, { time=200, x=200, y=100, yScale=0.5, xScale=0.5})     end local deplacement = transition.to( square, { time=200, x=150, y=100, yScale=2, xScale=2, onComplete=essai })

thanks again a nice jump effect

local eventx=300 local eventy=300 local persox=100 local persoy=100 if eventx==persox then nouvelleCoordonneex=eventx else nouvelleCoordonneex=eventx-persox end if eventy==persoy then nouvelleCoordonneey=eventy else nouvelleCoordonneey=eventy-persoy end  local function jump()  local square = display.newImage( "my2.png" )  square.x=persox  square.y=persoy  local function essai(square)         square:removeSelf()         local square=display.newImage( "my2.png" )          square.x=nouvelleCoordonneex          square.y=nouvelleCoordonneey         local deplacement2=transition.to( square, { time=250, x=eventx, y=eventy, yScale=0.5, xScale=0.5, transition=easing.outElastic})     end local deplacement = transition.to( square, { time=100, x=nouvelleCoordonneex, y=nouvelleCoordonneey, yScale=2, xScale=2, onComplete=essai, transition=easing.inBounce }) end jump()