Reputation: 11
I'm trying to make a game like DoodleJump. In the level(320x9600), position of an object(bar1_67)(of course there are lots of objects) is (177,263) and objects have physics shape. Requiring the "LevelHelper.LevelHelperLoader", I loaded the level:
...
local loader={}
--loading level
loader.level=LevelHelperLoader:initWithContentOfFile("level1.plhs")
loader.level:instantiateObjects()
loader.level:removeBackgroundColor()
local lhGroup=loader.level:layerWithUniqueName("MAIN_LAYER")
group:insert(lhGroup)
--to scroll the level, and start from the bottom of level
lhGroup.y=-loader.level.lhGameWorldRect.size.height+display.contentHeight
...
After this step, new Y position of the bar1_67 (according to the device screen) is about -9000s. Then I added the player, requiring the "SpriteHelper.SpriteHelperLoader":
...
sLoader = require("SpriteHelper.SpriteHelperLoader")
local _player={}
_player.player=sLoader:createSpriteWithName("player","sprites","extra.pshs")
_player.player:setReferencePoint(display.centerReferencePoint)
_player.player.x=display.contentWidth*0.5
_player.player.y=display.contentHeight*0.4
...
When starting the simulator, yes level was scrolled, but player collided with something invisible and stayed in the air. Then I added this code to see whats happening:
...
function aa(self,event)
if(event.phase=="began") then
print(event.other.x, event.other.y, event.other.lhUniqueName)
end
end
_player.player.collision=aa
_player.player:addEventListener( "collision", _player.player )
...
Output is :
177 263 bar1_67
But as I said level was scrolled and bar1_67 is out of screen. What can/should I do?
Upvotes: 1
Views: 96
Reputation: 160
Please use gamedevhelper.com forum in order to help you with LevelHelper related questions.
I don't know whats going on in this case but would it be possible for you to send me the project to have a look?
Upvotes: 0