Character falls off screen...

Currently, my player has a dynamic body and the tiles have a static body. I positioned the player so that he falls onto the tiles, instead of glitching into them, but nevertheless, this happens:

https://www.youtube.com/watch?v=irdZiXOMkfg&feature=youtu.be

If any code is needed, I am willing to give. 

Thanks in advance!

Can you share the code that adds bodies to your objects?

Yes, here it is:

--player.lua local offsetRectParams = {halfWidth = 53 / 4 \* 3, halfHeight = 60 / 4 \* 3} local anim = display.newSprite( sheet, sequenceData ) anim.x = x anim.y = y anim:setSequence("idle") physics.addBody(anim, "dynamic", {bounce = 0, box = offsetRectParams}) anim:play()

The code for the ground is added straight from Tiled. (see Screenshot)

I need to see all the unique addBody calls.

I’ve never used the box parameter before.  Have you tried removing it to see what effect that will have.

Maybe the values you’re using for box are changing the body offset too much.

It might simply be faster to zip it up and PM me like last time.

Alright, I will do that instead. (send it via PM)

You did this in main.lua:

local map = tiled.new( level1 ) map.x = -90 -- COMMENT THIS LINE OUT -- THEN MOVE YOUR PLAYER OVER IN THE EDITOR

You can’t move the group like that.  If you want to move the content, put all of your groups in a parent group and move the parent group.

You’re creating a situation where the player body is offset from the rest of the bodies.

https://www.youtube.com/watch?v=0OIBfDGOLig&feature=youtu.be

Oh, wow! I had no idea… So I add the player and the map into a parent group and move it all together. I read about physics offset, but I never thought I would have that problem.

Big thanks to you @roaminggamer:smiley:

Something like that.  I’m not 100% familiar with PonyTiled.  I use my own solution that is a mish-mash of my own loader and some key calculations/functions PonyTiled contains.  One of those differences is my systemuses the SSK2 quick layers system.  Thus I can just move the ‘layer’ container and all layers move with.

Well… that didn’t work.  <_<

I will just try to fill up the black area with something. Thanks again!

Dig deeper you’ll figure it out.

You really need to solve this so you can show the level correctly on different screens anyways.

I took the player out of a module, and placed it in a group and moved it over. It works, for the most part… It does not look to good on the iPhone 4S, but seeing as how 90% of people usually run to get newer iPhones without even thinking, hopefully, it will be ok. (Looks good on iPhone 5 and 6, 6s)

And SSK2’s camera stopped throwing errors. (My bad)

Killed two birds with one stone.  :slight_smile:

Can you share the code that adds bodies to your objects?

Yes, here it is:

--player.lua local offsetRectParams = {halfWidth = 53 / 4 \* 3, halfHeight = 60 / 4 \* 3} local anim = display.newSprite( sheet, sequenceData ) anim.x = x anim.y = y anim:setSequence("idle") physics.addBody(anim, "dynamic", {bounce = 0, box = offsetRectParams}) anim:play()

The code for the ground is added straight from Tiled. (see Screenshot)

I need to see all the unique addBody calls.

I’ve never used the box parameter before.  Have you tried removing it to see what effect that will have.

Maybe the values you’re using for box are changing the body offset too much.

It might simply be faster to zip it up and PM me like last time.

Alright, I will do that instead. (send it via PM)

You did this in main.lua:

local map = tiled.new( level1 ) map.x = -90 -- COMMENT THIS LINE OUT -- THEN MOVE YOUR PLAYER OVER IN THE EDITOR

You can’t move the group like that.  If you want to move the content, put all of your groups in a parent group and move the parent group.

You’re creating a situation where the player body is offset from the rest of the bodies.

https://www.youtube.com/watch?v=0OIBfDGOLig&feature=youtu.be

Oh, wow! I had no idea… So I add the player and the map into a parent group and move it all together. I read about physics offset, but I never thought I would have that problem.