Hey everyone, I have some code here that creates a boat and pirate on top of it. The boat rotates randomly as the pirate slips off , everything works pretty fine except for when the boat is rotating the physics of the pirate run very slowly and its not as smooth as I would like it to be. If anyone has any comments or can help me out please do, thanks a lot.
-Caine
[code]
local sprite = require (“sprite”)
local physics = require(“physics”)
physics.start(true)
physics.setGravity(0, 9.81)
physics.setVelocityIterations( 6 )
local H = display.contentHeight
local W = display.contentWidth
local mRand = math.random
----functions-------
local call_start = {}
local gamePlay
local max_r
local trans
set_up = function()
gamePlay = display.newGroup()
local pirate_s = sprite.newSpriteSheet( “pirate.png”, 60, 70 )
local pirate_s2 = sprite.newSpriteSet(pirate_s, 1, 5)
sprite.add( pirate_s2, “still”, 1, 1, 100, 1 )
sprite.add( pirate_s2, “walk”, 2, 3, 300, 0 )
sprite.add( pirate_s2, “jump”, 5, 1, 100, 1 )
pirate = sprite.newSprite( pirate_s2 )
pirate.x, pirate.y = W/2 , H/2
physics.addBody( pirate, “dynamic”, { density=10.5,friction=0.01, bounce=0.0 } )
pirate.isBullet = true
gamePlay:insert(pirate)
boat = display.newImage(“boat.png”,90,200)
physics.addBody( boat, “static”, { density=1.0,friction=0.1, bounce=0.0 } )
gamePlay:insert(boat)
call_start()
end
local function rotate_boat()
max_r = 25
local boatr = mRand(-max_r,max_r)
local boat_rs = mRand(1000, 3000)
trans = transition.to( boat, { time=boat_rs, rotation=(boatr), onComplete=rotate_boat } )
end
call_start = function()
rotate_boat()
end
set_up
[import]uid: 75991 topic_id: 23110 reply_id: 323110[/import]
