I have a problem with perspective.lua (camera movement library) and my game. Urgent help please.

Hi I am 2d game that uses Dusk lib, perspective lib and tiled. This is what I have created so far:

https://www.youtube.com/watch?v=54-Wd1Rxxvs&feature=youtu.be

Here is the code:

local composer = require("composer") local dusk = require("Dusk.Dusk") local physics = require("physics") local perspective = require("Libs.perspective") local camera = perspective.createView() local scene = composer.newScene() physics.start() physics.setDrawMode("hybrid") function scene:create(event) local view = self.view -- Cordinates local \_X = display.contentCenterX local \_Y = display.contentCenterY local \_W = display.contentWidth local \_H = display.contentHeight -- Buttons local buttonSize = 60 local buttonAlpha = 0.5 --Other local jumped = true local gameOn = true -- Set up background display.setDefault("background", 1,1,1) local map = dusk.buildMap("Levels/Level1.json") camera:add(map, 2) --view:insert(map) -- Set up the sprites local function setupSprites() sheetData = { width = 128, height = 128, numFrames = 8, sheetContentWidth = 1024, sheetContentHeight = 128 } sequenceData = { {name = "normalRun", start = 1, count = 8, time = 1000} } mySheet = graphics.newImageSheet("Sprites/Walk.png", sheetData) end setupSprites() -- Show the character local animation = display.newRect(\_X, \_Y, 100, 100) animation.x = \_X animation.y = \_Y --animation:play() physics.addBody(animation, {bounce = 0, shape = {-animation.width / 4,-animation.height / 2.5, animation.width / 7,-animation.height / 2.5, animation.width / 7,animation.height / 2, -animation.width / 4,animation.height / 2}}) camera:add(animation, 1) --view:insert(animation) camera:setFocus(animation) camera:track() -- animation:play() animation:pause() animation:setFrame() animation:setSequence() local function createButtons() if gameOn then leftButton = display.newRect(\_X - \_W/2.5, \_Y + \_H/4, buttonSize, buttonSize) leftButton:setFillColor(0,0,0) leftButton:toFront() leftButton.alpha = buttonAlpha view:insert(leftButton) rightButton = display.newRect(leftButton.x + \_W/5, \_Y + \_H/4, buttonSize, buttonSize) rightButton:setFillColor(0,0,0) rightButton:toFront() rightButton.alpha = buttonAlpha view:insert(rightButton) jumpButton = display.newRect(\_X + \_W/2.5, \_Y + \_H/4, buttonSize, buttonSize) jumpButton:setFillColor(0,0,0) jumpButton:toFront() jumpButton.alpha = buttonAlpha view:insert(jumpButton) end end createButtons() local function movePlayer() motionx = 0 -- Variable used to move character along x axis speed = 5 -- Set Walking Speed local function moveLeft(event) if "began" == event.phase then print("L button pressed") motionx = - speed end if "ended" == event.phase then motionx = 0 end end local function moveRight(event) if "began" == event.phase then print("R button pressed") motionx = speed end if "ended" == event.phase then motionx = 0 end end local function moveUp(event) if "began" == event.phase then if (jumped == false) then jumped = true animation:setLinearVelocity( 0, -250 ) print("HYPPY") end end end local function onCollision(event) if ( event.phase == "began" ) then jumped = false print(lol) end end local function moveguy(event) animation.r = 0 animation.x = animation.x + motionx end Runtime:addEventListener("enterFrame", moveguy) leftButton:addEventListener("touch", moveLeft) rightButton:addEventListener("touch", moveRight) jumpButton:addEventListener("touch", moveUp) Runtime:addEventListener("collision", onCollision) end movePlayer() end function scene:show(event) end function scene:hide(event) end function scene:destroy(event) end scene:addEventListener("create") scene:addEventListener("show") scene:addEventListener("hide") scene:addEventListener("destroy") return scene

My problem is that I want the physic bodies stay inside the images. (BTW: I removed my sprite from the video, so that no-one can copy it.)

Bump

We fixed a bug a while back that had the unfortunate side-effect of causing the physics object to not draw on top of the display object in hybrid draw mode. We reverted that change last week. Please grab the latest daily build and see if that addresses your issue.

Rob

Thanks Rob! It helped!

Bump

We fixed a bug a while back that had the unfortunate side-effect of causing the physics object to not draw on top of the display object in hybrid draw mode. We reverted that change last week. Please grab the latest daily build and see if that addresses your issue.

Rob

Thanks Rob! It helped!