How to detect an instance of a sprite at X and Y

Get help using Construct 2

Post » Thu Dec 26, 2013 12:40 pm

Is there a way to detect and instance of sprite at a given X and Y?
B
17
S
3
Posts: 33
Reputation: 1,666

Post » Thu Dec 26, 2013 1:04 pm

Yes, but the question is how would you like to detect it and what would you like to detect?

you could just use
Sprite compare x and sprite compare y
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 » Thu Dec 26, 2013 1:26 pm

Good question ... I am moving a sprite based on keyboard input using SetX or SetY, depending on the key pressed. What I would like to do is add a condition that will check just to make sure a specific sprite, say a Wall, is not in the spot they are moving into.
B
17
S
3
Posts: 33
Reputation: 1,666

Post » Thu Dec 26, 2013 1:49 pm

I guess you could use an inverted is overlapping at offset event.

on left key pressed
sprite is not overlapping wall at offset (value of moving left)
- sprite move left.
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 » Thu Dec 26, 2013 4:47 pm

I'm still struggling with this ... Could you take a look a this project and let me know what you think ...

https://www.dropbox.com/s/71nrbu9mbra0r5p/SampleSpriteDetection.capx

Press the down arrow should stop the sprite at the red wall.

Thanks for the help!
B
17
S
3
Posts: 33
Reputation: 1,666

Post » Thu Dec 26, 2013 9:22 pm

the overlap offset is an offset not a new position so make your offset (0,-32) not (sprite.x,sprite.y-32)

it might work better if you reduce your collision boxes slightly or maybe make the offset slightly smaller to stop any touch ? (I will go and test this theory...)

edit to add picture


RamPackWobble2013-12-26 21:39:30
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 » Thu Dec 26, 2013 9:34 pm

yeap - I would (if using your method) reduce the collision boxes slightly to allow for a small border - reducing the chance of the sprites touching.

I think that them even touching will cause this to fail ?
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 » Fri Dec 27, 2013 11:26 pm

Was really hoping to keep the sprites all the same size ... thought this would be easier. Thanks for looking into this.
B
17
S
3
Posts: 33
Reputation: 1,666

Post » Mon Dec 30, 2013 11:15 pm

not reduce the sprites but their collision polygon in built in image editor. (sorry missed your reply)
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 Dec 31, 2013 12:47 am

Gotcha! Didn't know about the collision polygon. That would work.
B
17
S
3
Posts: 33
Reputation: 1,666

Next

Return to How do I....?

Who is online

Users browsing this forum: VValt and 23 guests