Does anyone know a good way to detect collisions between two sprites on two different layers.
Thanks
Cross-layer collision detection
(6 posts) (3 voices)-
Posted 2 years ago #
-
It should be the same as if they were in the same layer.. right? Just compare their position.
Unless you're using a physic engine for it and each one is in a different layer?
Posted 2 years ago # -
Sorry if I seem to be way off.. I'll blame it on the late hours :)
Posted 2 years ago # -
Kinda new to this, but I think I figured it out. You didn't give me the answer I was looking for but it got my brain working.
Thanks.Posted 2 years ago # -
Hey Fletch
Do you mind posting what you ended up doing? i may be needing the same thing in my game.
Thanks
-LarsPosted 2 years ago # -
Lars,
Well so far I'm giving the sprite instances tags then using 'getChildByTag'
-example in the layer i add the sprite with a tag like this
[self addChild:sprite tag:1]
-Then in the scene I get the sprite using
[layer getChildByTag:1]I just don't know if this is the best way I should be going about doing this. If anyone knows an easier or better solution let me know.
Posted 2 years ago #
Reply
You must log in to post.