How to interact with the sprites according to its position

Get help using Construct 2

Post » Wed Nov 04, 2015 5:38 pm

Hi everybody

I need to change the sprites according its position. The sprites will falling and others will be create in the same place. So, when the sprite is in the specific position, it shows frame 1 when it come down to a position below it changes from frame 1 to frame 0. I need only to detect the sprites and change the frame (I don't need the commands to move the sprites ).

I create a simple capx to illustrate it.

https://www.dropbox.com/s/42iji832fisa4 ... .capx?dl=0

Thanks in advance for any help.
B
74
S
14
G
4
Posts: 1,038
Reputation: 8,179

Post » Wed Nov 04, 2015 5:54 pm

Not capable to have a look at the capx, but would a sprite compare y > 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 » Wed Nov 04, 2015 6:07 pm

@LittleStain

Any problem to open the file?

Here are the corresponding images:

Image
B
74
S
14
G
4
Posts: 1,038
Reputation: 8,179

Post » Wed Nov 04, 2015 6:16 pm

So when do you want which sprite to change animation?
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 » Wed Nov 04, 2015 6:50 pm

That "system compare" doesn't pick anything so all the frames will change if the first instance of sprite makes the condition true. To fix use "pick by comparison" instead or add a "for each sprite" above the compare.
B
94
S
33
G
123
Posts: 5,453
Reputation: 78,469

Post » Wed Nov 04, 2015 6:57 pm

@LittleStain: Whenever any instance is in these positions.

@R0J0hound: I've tried to use "for each sprite" but nothing happened. I'll try the "pick by comparison"

***Edited: "Pick by comparison" didn't work too.
B
74
S
14
G
4
Posts: 1,038
Reputation: 8,179

Post » Wed Nov 04, 2015 7:27 pm

try
Image
Image
B
67
S
24
G
7
Posts: 1,519
Reputation: 11,084

Post » Wed Nov 04, 2015 8:12 pm

The condition can never be true. Logical expression only ever equals 0 or 1, not 384. Also, after testing out your capx, it seems the "|" operator is not evaluated in the order it should, so I could only make it work by adding parenthesis.

Code: Select all
(Sprite.X = 256 & Sprite.Y = 96) | (Sprite.X = 640 & Sprite.Y = 96) | (Sprite.X = 256 & Sprite.Y = 384) | (Sprite.X = 640 & Sprite.Y = 384)

equals to 1.

This, together with a for each should make your capx work.
B
78
S
32
G
27
Posts: 1,021
Reputation: 20,952

Post » Wed Nov 04, 2015 9:19 pm

Thank you @korbaach and @Magistross

@Magistross: I understood (0 is always false / 1 is true, right?). It works very well. Thanks.

As I said, the sprites will fall and when it changes to a different position from the one I've specified in the "pick comparison", I need the sprite to return to its default frame (0). I tried to use "else" to do this but it's no work. Do you have any idea how to solve this?

***Edit: Everything is okay now. Thanks.
B
74
S
14
G
4
Posts: 1,038
Reputation: 8,179


Return to How do I....?

Who is online

Users browsing this forum: mikewalton206 and 26 guests