I decided to try Perspective and added it to a simple test case, however when player go to either side of the screen I expect it to switch sides. It works without the library.
Any ideas how to wrap objects when using Perspective?
Thanks.
[lua]
local composer = require(“composer”)
local scene = composer.newScene()
local perspective = require(“perspective”)
local camera = perspective.createView()
camera.damping = 5
– Inside the
local W = display.contentWidth
local H = display.contentHeight
– “scene:create()”
function scene:create(event)
local sceneGroup = self.view
local player = display.newRect( sceneGroup, W/2 , H/2, 64, 64 )
local motionX = 0
local function onAccelerate(event)
motionX = 10 * event.xGravity
– go off left side
if ( player.x + (player.contentWidth*0.5) ) < 0 then
player.x = W + (player.contentWidth*0.5)
– go off right side
elseif ( player.x - (player.contentWidth*0.5) ) > W then
player.x = W - (player.contentWidth*0.5)
end
player:translate(motionX,0)
end
Runtime:addEventListener(“accelerometer”, onAccelerate)
camera:add(player, 1, true)
camera:toPoint(W/2 , H/2)
camera:setBounds(0, W, 0, H )
end
– “scene:show()”
function scene:show(event)
local sceneGroup = self.view
local phase = event.phase
if (phase == “will”) then
elseif (phase == “did”) then
camera:setFocus(player)
camera:track()
end
end
[/lua]