Touch != Collision

Get help using Construct 2

Post » Wed May 09, 2012 9:38 am

I have a problem in my game with collisions, I need a very small collision polygon but at the same time I need for the whole object to be touched.

What I mean is that touch must be triggered upon touching any part of the sprite (the whole thing) while if I'm testing for collision with another sprite I need to check only a very small area.

How can I do this?
B
29
S
9
G
6
Posts: 525
Reputation: 8,294

Post » Wed May 09, 2012 10:15 am

The usual trick is to use invisible sprites positioned over the object as a separate collision mask.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,468

Post » Wed May 09, 2012 10:25 am

@Ashley Thanks, I though about that, but what is the impact on performance (I'm on mobile so it's important)?

It's a puzzle game so there is an important amount of sprites on screen (around 40 which having their own sprite on top would mean 40visible + 40 invisible).
B
29
S
9
G
6
Posts: 525
Reputation: 8,294

Post » Wed May 09, 2012 10:49 am

@0plus1
Here's what I made. Would this be something you need?
http://dl.dropbox.com/u/53898431/Junk/Touch_collision_example.capxnemo2012-05-09 10:54:39
B
40
S
5
G
5
Posts: 405
Reputation: 5,657

Post » Wed May 09, 2012 11:46 am

I doubt there would be any more loss of performance than if you had multiple collision masks. They are essentially doing the same thing, at the end of the day.

That being said, multiple collision masks on single objects are on Ashley's to-do list, albeit quite far back (as more important stuff is needed beforehand, and that this has a workaround).

Use the 'pin' behavior so that you don't have to worry about it.
B
14
S
1
G
2
Posts: 85
Reputation: 2,810

Post » Wed May 09, 2012 12:09 pm

@0plus1 - since performance is 90% rendering, if the sprite is invisible, there will not be any significant performance impact.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,468


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 24 guests