Hey All,
I’ve been working on this game for a few weeks.
My character can roll into these small tunnels(see image).
I have a simple function to check if the character is in a tunnel, it goes something like this:
If the player’s x position is more than the tunnel’s x position the player is in the tunnel.
player.setSize(30, 80, true)
if (player.x > platform.x) {
// Player appears to be in tunnel
inTunnel = true
}
It does work as intended, the only problem seems to be that the x position is based on the players original frame size:
sceneParam.load.spritesheet('hero',
'assets/player-idle.png',
{ frameWidth: 192, frameHeight: 94 }
)
So in the image you can see that even though I’ve set the player’s size, the x position is technically less than the tunnel because it’s basing it’s x position on the original frame size(the debug test in the image illustrates what i mean).
I’ve tried using player.body.sourceWidth
, player.displayWidth
but it doesn’t seem to base the position on the size I have set.
Does any one know what I can do?
Thank you all
Moe