For my side scrolling game, I'm using an invisible rectangle for collision detection. I pin my main sprite to the location of the rectangle which is updated "every tick". When the main sprite jumps on solid tiles, the collision detection works perfectly about 50% of the time. But half the time, the sprite will sink 1 pixel into the ground.
Because my game is low resolution (screen 256, 240) and my main sprite is only 29x30, a single pixel off is noticeable. I've verified that the Y coordinate is the same regardless of whether the sprite appears to be "on the ground" like normal or "sunken into the ground".
Any ideas? Or is pixel perfection just not plausible? I could always multiply everything in my game by a factor of 4 for example so that the sinking in would only appear to be 1/4th the depth of a pixel but I'd rather fix the problem than mask it.
I think that the 1 px error is a render problem, or the engine has to aproximate a distance < 1px, and that's why. If you show us a bit of your code maybe we can be more specific.
There are a few reasons this happens. An easy fix is to check if the player is both on the floor and overlapping a collision tile. If so, move the player up one pixel.
I examined the example that comes with Construct 2 "Platform 1, Simple Movement" and I see it has the same 1 pixel error. So I have to assume it's just a fundamental flaw in the system. My code is nothing special. Just a jumping box for a sprite that is my main character and some solid sprites to jump on.
Develop games in your browser. Powerful, performant & highly capable.
Tokinsom, I'll try messing with those two thing. I already verified that my sprite is at the same Y position regardless of whether it is on the floor or sunken into the floor.
Have you tried turning pixel rounding on on the project properties? ;]
It's not pixel rounding issue, it's the way C2 platform behavior works. Many people have noticed this before.
Read this, this, and this.
Your only solution is custom platform engine with loops, becouse C2 is against the old school <img src="smileys/smiley2.gif" border="0" align="middle">, but thats not so hard to pulloff and most of all with custom platform engine you can have variable jumps <img src="smileys/smiley36.gif" border="0" align="middle">
in this you never hit ceiling (pixel rounding On)