Comparing Frames

Get help using Construct 2

Post » Wed Nov 30, 2016 9:19 am

Good day. I just want to compare my frames from sprite1 to the frames of sprite2 without having too much events everytime i compare the two. (How can i make a short version of long method but has the same function)

Please take a look at my example capx

(UPDATED CAPX)
http://www.fileconvoy.com/dfl.php?id=gf ... 54ef614044
Last edited by jance0405 on Tue Dec 20, 2016 10:26 am, edited 2 times in total.
B
30
S
12
G
4
Posts: 67
Reputation: 4,250

Post » Wed Nov 30, 2016 9:46 am

jance0405 wrote:Good day. I just want to compare my frames from sprite1 to the frames of sprite2 without having too much events everytime i compare the two.

Please take a look at my example capx

http://www.fileconvoy.com/dfl.php?id=g8 ... 4f2b1bb17c


Think you have to explain in more details what you are trying to achieve with this, if you want help finding alternatives. When looking at you Capx, it seems that different things should happen if for instant (Sprite_1.Animation_frame 1 = Sprite_2.Animation_frame 1) but also if (Sprite_1.Animation_frame 1 = Sprite_2.Animation_frame 2) and so forth.

But regardless of whether you use | in your condition, if you want different things to happen based on which condition is true, you will need to figure out which frame each of these were at some point and therefore use a lot of conditions.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Wed Nov 30, 2016 10:00 am

Just use a for loop and name your loops

For "loop1" from 1 to 12000 -> for "loop2" from 1 to 12000 -> if sprite2.animationframe = loopindex("loop1") -> if sprite1.animationframe = loopindex("loop2") -> do this
B
125
S
43
G
41
Posts: 849
Reputation: 28,260

Post » Wed Nov 30, 2016 10:07 am

andreyin wrote:Just use a for loop and name your loops

For "loop1" from 1 to 12000 -> for "loop2" from 1 to 12000 -> if sprite2.animationframe = loopindex("loop1") -> if sprite1.animationframe = loopindex("loop2") -> do this


I don't see how that would reduce the work a whole lot, but might have misunderstood what he is trying to do?

But if loop1(10240) = loop2(9020) should do something different than loop1(11002) = loop2(4030) then you would still need to add this to the code somewhere, resulting in a lot of events.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Wed Nov 30, 2016 11:11 am

andreyin wrote:Just use a for loop and name your loops

For "loop1" from 1 to 12000 -> for "loop2" from 1 to 12000 -> if sprite2.animationframe = loopindex("loop1") -> if sprite1.animationframe = loopindex("loop2") -> do this


Thank you but it doesnt work.

I dont know how can i do this in construct 2 but how can i do the "Or statement" in construct 2?

Example:
0 or 1 or 2 or 3 or 4 or 5............or 100
B
30
S
12
G
4
Posts: 67
Reputation: 4,250

Post » Wed Nov 30, 2016 11:15 am

You could use a "is between" comparison.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Wed Nov 30, 2016 11:20 am

I tried this | "Pipe" symbol, construct 2 accepts it but when i run it, the other frames doesn't work.

Example:

Event:
sprite1frame = 0
sprite2 frame = 0 | 1 | 2 | 3 | 4 | 5

Action:
System go to layout 2

On this example, only the frame 0 of sprite1 and frame 1 of sprite2 will work. The other frames seems to not work
B
30
S
12
G
4
Posts: 67
Reputation: 4,250

Post » Wed Nov 30, 2016 11:36 am

jance0405 wrote:I tried this | "Pipe" symbol, construct 2 accepts it but when i run it, the other frames doesn't work.

Example:

Event:
sprite1frame = 0
sprite2 frame = 0 | 1 | 2 | 3 | 4 | 5

Action:
System go to layout 2

On this example, only the frame 0 of sprite1 and frame 1 of sprite2 will work. The other frames seems to not work


Its because you think the | works in a different way than it does.

The | will return true or false depending on whether one of the Or conditions are correct.

So it should look like this:

If Sprite.frame = 0 | Sprite.frame = 1 | Sprite.frame = 2
= 1

Then it will return true and therefore condition is true as well. If Sprite.frame is not 0, 1 or 2 then it will return false.

So its not a functionality where you can ask in the sense of whether Sprite.frame is 0,1,2.....100 and if that's that the case do something. Well you can but you have to write it as I did above and compare it to either 0,1 (False, True)
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Wed Nov 30, 2016 11:48 am

nimos100 wrote:
jance0405 wrote:I tried this | "Pipe" symbol, construct 2 accepts it but when i run it, the other frames doesn't work.

Example:

Event:
sprite1frame = 0
sprite2 frame = 0 | 1 | 2 | 3 | 4 | 5

Action:
System go to layout 2

On this example, only the frame 0 of sprite1 and frame 1 of sprite2 will work. The other frames seems to not work


Its because you think the | works in a different way than it does.

The | will return true or false depending on whether one of the Or conditions are correct.

So it should look like this:

If Sprite.frame = 0 | Sprite.frame = 1 | Sprite.frame = 2
= 1

Then it will return true and therefore condition is true as well. If Sprite.frame is not 0, 1 or 2 then it will return false.

So its not a functionality where you can ask in the sense of whether Sprite.frame is 0,1,2.....100 and if that's that the case do something. Well you can but you have to write it as I did above and compare it to either 0,1 (False, True)


i think there is no other way but to compare it 1 by 1 :(
B
30
S
12
G
4
Posts: 67
Reputation: 4,250

Post » Wed Nov 30, 2016 12:04 pm

jance0405 wrote:i think there is no other way but to compare it 1 by 1 :(


Might not :D

Depends on what you are trying to achieve.

The only reason I can see you wanting to use the | expression, is if you wanted to compare both sprites, like this:

Sprite1.frame = 0 | Sprite1.frame = 1 = Sprite2.frame = 0 | Sprite2.frame = 1

But in most cases I would still think using simple conditions like "Is between" and basic "Sprite1.Frame = 0" would make it easier to work with. Personally I haven't used | a lot, as I haven't really run into something where it would be extremely useful, but maybe someday :D
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Next

Return to How do I....?

Who is online

Users browsing this forum: DiegoSanudoDT, R0J0hound and 11 guests