I have seem to run into a strange behavior which I suspect is related to the “Test if a point is inside object collision mask” event. My game is emulating a physical puzzle where the player places various different sized pieces into a tray.
In the GDevelop simplified version attached, the “tray” is a sprite 280 x 280 px in size and is offset 20 px from the edge of the scene.
The tray is surrounded by a 5 px wide border (sprite) that will change color if a piece is placed on top of one of the border edges.
If a piece is completely inside the tray area, it will snap to the nearest (rounded) intersection when the mouse is released.
Each piece has the following Points defined based on the rectangle surrounding the object:
UL - upper left corner (0,0)
LR - lower right corner (depends on size of shape)
Origin - set to the CENTER of the piece
(in the full game, the shapes can be flipped and rotated, so the origin needs to be the center of the object. The UL and LR points effectively delineate the object rectangle for the “point inside object collision mask” test no matter how the piece is rotated or flipped).
Now that you have some background, the issue:
If the right edge of a piece is placed against the right most edge of the tray (in the example, the Shape.PointX(“LR”) = 300), OR if the bottom edge of a piece is placed against the bottom most edge of the tray (Shape.PointY(“LR”) = 300) the following event test fails:
If all these conditions are true:
Shape.PointX(“UL”); Shape.PointY(“UL”) is inside Tray
Shape.PointX(“LR”); Shape.PointY(“LR”) is inside Tray
if the shape is moved to 299, the snap works perfectly.
Note that the Left and Top borders work properly, and I’ve tried this in my full version with a rotated/flipped shape with the same results.
I’ve verified the HitBox for Tray is 280x280 and I’ve check the UL and LR points on each shape - all are correct.
I would really appreciate it if someone could tell me why this very narrow case is causing my code to malfunction. It may seem minor (it is only 1 px after all), but it is driving me crazy.
Thanks,
Art.
Example project can be downloaded from: Collision Mask Issue