has anyone got an example of the code needed for the springing?
i am trying to understand how you work it out but am having no joy,
ive managed to make the head on mine move based on the acclerometer, but cannot get it to spring back
please add to this code if possible
local piratebod = display.newImage (“body.png”, 90,290)
–Head
local head = display.newImage(“head.png”, 140,44)
head:setReferencePoint(display.CenterReferencePoint)
head.x = display.contentWidth * 0.6
head.y = display.contentWidth * 0.3 + 140
–skullbutton
local skull = display.newImage (“button.png”, 10,640)
– Listen for Accelerometer Events
local acc = {}
local centerX = display.contentWidth * 0.5
function acc:accelerometer(e)
head.x = centerX + (centerX * e.xGravity)
end
Runtime:addEventListener(“accelerometer”, acc)
local max = math.max
local min = math.min
local centerX = display.contentWidth/2
local function rotate(event)
local r = event.x - centerX – (shift values to between eg -240 to 240)
r = min(r, 30) – no higher than 30
r = max(r, -30) – no lower than -30
head.rotation = r
end
background:addEventListener( “touch”,rotate) [import]uid: 45019 topic_id: 1421 reply_id: 28372[/import]