Without changing anything my code just doesn’t do the same (it’s the first time for the last 2 years that I use Corona that such a thing happens).
Maybe it’s a bug related to 2.2.1 box2d update…
Here is a sample code and the issue explained in the comment :
-----------------------------------------------------------------------------------------
-- main.lua
-----------------------------------------------------------------------------------------
-- hide the status bar
display.setStatusBar( display.HiddenStatusBar )
-- setup :
local physics = require "physics"
physics.start()
physics.setGravity( 0, 0 )
physics.setDrawMode( "hybrid" )
local function getPositions( x, y, angle, distance )
local mPi = math.pi;local mCos = math.cos;local mSin=math.sin; local mCeil=math.ceil
return { mCeil(x + (distance \* mCos((angle-90) \* mPi / 180))), mCeil(y + (distance \* mSin((angle-90) \* mPi / 180))) }
end
local indices={}
-- 1 the center :
local center = display.newCircle( 160, 240, 5 )
center:setFillColor(200,0,0,255)
-- physics for rotation
physics.addBody( center, "static", { radius=5 })
-- 2 the rectangles :
local function doObject( angle, distance)
-- the object :
local object=display.newRect( 0, 0, 5, 30 )
object:setFillColor(200,0,200,255)
-- place the object
indices = getPositions( 160, 240, angle, distance )
object:translate( indices[1], indices[2] )
object:rotate(angle)
-- physics for rotation
physics.addBody( object, "dynamic", { isSensor = true, radius=5 } )
physics.newJoint( "pivot", object, center, 160, 240 )
return object
end
local objects={}
for i=1, 5 do
objects[i]=doObject(math.random(360), 150)
end
-- 3 the rotation :
local function mainloop( event )
for i=1,#objects do
objects[i]:rotate(10)
-- HERE IS THE BUG
-- in sdk 840, the speed is about 1 turn in 2 seconds
--\> in sdk 894, the speed is QUITE SLOWER !!!
-- trying to catch up the speed by increasing rotate(50)
-- increases A LOT the aiming poblem (rectangles are not aiming at the center dot)
end
end
-- pause :
local text = display.newText( "PAUSE", 0, 0, native.systemFont, 30 )
text.x = 160
text.y = 460
text:setTextColor( 255,110,110 )
local isPause=false
local function pause( event )
if event.phase == "began" then
if isPause==false then
Runtime:removeEventListener("enterFrame", mainloop)
isPause=true
text.text="PAUSE"
else
Runtime:addEventListener("enterFrame", mainloop)
isPause=false
text.text="RUNNING"
end
end
end
text:addEventListener("touch",pause)
Thx [import]uid: 9328 topic_id: 30607 reply_id: 330607[/import]
[import]uid: 52491 topic_id: 30607 reply_id: 125234[/import]