Touch Event hitting two objects

Get help using Construct 2

Post » Tue Feb 18, 2014 7:38 am

Hi all,

I have items falling on screen, and when you tap on them you get -1 from your 'hit count'

if you miss them and tap the background you also get -1 from your 'hit count'

I have Touch Event setup for On Touch - ObjectA, and another for On Touch - Object B(background)

When I tap on the background object there is no issue, but when I tap on the falling object, it registers the tap on both the object.

These are on different layers if that makes a difference.


I was trying to find a way to basically to do;

Touch - If object = ObjectA then this, else this. But cant seem to find these conditions?

Is there a smarter way I should be setting this up?
B
4
Posts: 18
Reputation: 230

Post » Tue Feb 18, 2014 8:01 am

First thought (not tested)

two variables gvScreenTouched and gvSpriteTouched

on any touch start -- add 1 to gvScreenTouched
(sub event)
--touch is touching sprite -- take 1 from gvScreenTouched
                           -- add 1 to gvSpriteTouched
                           -- sprite destroy
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,892

Post » Tue Feb 18, 2014 8:11 am

Would adding an is not touching objectA condition to the on touched objectB event work?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Feb 18, 2014 9:58 am

[QUOTE=LittleStain] Would adding an is not touching objectA condition to the on touched objectB event work?[/QUOTE]

Would I do that by using the 'invert' is touching sprite?

if so it doesnt :(
B
4
Posts: 18
Reputation: 230

Post » Tue Feb 18, 2014 10:12 am

Just do if (touching falling sprite) +0.. since you only want to subtract one, you're already subtracting one from the background. If you want to add 1 point for touching something else, go +2 to that object. I guess just offset everything by -1.
B
6
S
2
Posts: 29
Reputation: 581

Post » Wed Feb 19, 2014 3:08 am

[QUOTE=Ainxty] Just do if (touching falling sprite) +0.. since you only want to subtract one, you're already subtracting one from the background. If you want to add 1 point for touching something else, go +2 to that object. I guess just offset everything by -1.[/QUOTE]

Yeah I ended up not doing -1 on hitting the Object A, works as intended now although prob not the best implementation
B
4
Posts: 18
Reputation: 230


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 13 guests