How to tell if an object is above another object

Hiya Guys/Gals,

I am trying to use the best method to determine whether an object is above another object (object is an image of a box). By above I mean directly lying on top of it, touching.

Currently, I am using simple object1.x,object1.y comparison against object2.x,object2.y, it works, but im not sure if thats the best way.

Surely there must be a better method?

Many Thanks
Warren [import]uid: 114931 topic_id: 22603 reply_id: 322603[/import]

Using Y coords is your best bet, although if using physics there may be some other options. (Not necessarily better options, though.) [import]uid: 52491 topic_id: 22603 reply_id: 90149[/import]

Hi Peach,

Thanks for the reply.

Using physics, what would the other options be? It just so happens that my game is physics based :slight_smile:

Thanks
Warren

[import]uid: 114931 topic_id: 22603 reply_id: 90157[/import]

Warren,

Peach is talking about collision events that take place when using the physics engine. You can find out more about it here:

http://developer.anscamobile.com/content/game-edition-collision-detection

In a nutshell, you don’t have to check for one object touching another – you just set up an event listener that will be called when the collision takes place.

Jay
[import]uid: 9440 topic_id: 22603 reply_id: 90191[/import]

Thanks Peach and Jay, I will look into that :slight_smile: [import]uid: 114931 topic_id: 22603 reply_id: 90766[/import]