Hi all,
I am trying to create something similar to Doodle Jump game, and i am using RGCamera library:
https://github.com/roaminggamer/RGCamera
Tnx RoamingGamer!
I have two problems:
- When “Smiley” (the player) jumps he gets to close to the upper edge of the screen (portrait orientation).
How to keep player in 2/3 or half of bottom part of screenHeight?
- I have applied physics to the player (dynamic object) and to the circles (static objects).
My problem is when “Smiley” (the player) jumps (setLinearVelocity) and then falls down, as he is falling down the circles (static objects) are moving up.
How to make that as he falls down the circles (static objects) are NOT moving up (like in Doodle Jump)?
Basically I want that camera follows circles only in -Y direction ** (UP) ** -_-
Many many many thanks! 
GG
Code here (you have it on above link also).
-- ============================================================= -- Step 1. - Load RGCamera -- ============================================================= local camera = require "RGCamera" -- ============================================================= -- Step 2. - The example -- ============================================================= -- -- Tip: Camera selection is at bottom of this file. -- -- -- a. Set up some useful variables -- local centerX = display.contentCenterX local centerY = display.contentCenterY local w = display.contentWidth local h = display.contentHeight local fullw = display.actualContentWidth local fullh = display.actualContentHeight local left = centerX - fullw/2 local right = centerX + fullw/2 local top = centerY - fullh/2 local bottom = centerY + fullh/2 -- -- b. Create rendering layers for our game with this -- final Layer Order (bottom-to-top) -- --[[ display.currentStage\ |---\underlay | |---\content | |---\overlay --]] layers = display.newGroup() layers.underlay = display.newGroup() layers.content = display.newGroup() layers.overlay = display.newGroup() layers:insert( layers.underlay ) layers:insert( layers.content ) layers:insert( layers.overlay ) -- -- c. Randomly populate the world with random circles -- for i = 1, 250 do local x = math.random( left - fullw, right + fullw ) local y = math.random( top - fullw, bottom + fullw ) local radius = math.random(10,15) local circle = display.newCircle( layers.content, x, y, radius ) circle:setFillColor( math.random(), math.random(), math.random() ) circle.alpha = 0.25 physics.addBody(circle, "static", {desity = 1.0, friction = 1.0, bounce = 0.2}) end -- -- d. 'Frame' legal bounds of 'world' -- local tmp = display.newRect( layers.content, centerX, centerY, fullw, fullh ) tmp:setFillColor(0,0,0,0) tmp:setStrokeColor(1,0,0) tmp.strokeWidth = 2 -- -- Move the player upwards local function movePlayer(event) player:setLinearVelocity(0, -500) end -- -- e. Create a 'player' as the camera target -- local player = display.newImageRect( layers.content, "smiley.png", 40, 40) player.x = centerX player.y = centerY physics.addBody(player, "dynamic", {desity = 1.0, friction = 1.0, bounce = 0.2}) player:addEventListener("tap", movePlayer) -- -- g. Attach a camera to the player and the 'world' -- -- Uncomment any ONE of the following lines to see that camera in action -- camera.tracking( player, layers.content ) --camera.tracking( player, layers.content, { lockX = true, lockY = false } ) --camera.tracking( player, layers.content, { lockX = false, lockY = true } ) --camera.trackingLooseSquare( player, layers.content, { boundarySize = 100 } ) --camera.trackingLooseSquare( player, layers.content, { boundarySize = 160 } ) --camera.trackingLooseCircle( player, layers.content, { debugEn = true } ) --camera.trackingLooseCircle( player, layers.content, { bufferSize = fullh/2, deadRadius = 0, debugEn = true } ) --camera.trackingLooseCircle( player, layers.content, { bufferSize = 10, deadRadius = fullh/2 - 10, debugEn = true } )
