How do I pick only one sprite by comparission

Get help using Construct 2

Post » Mon Jul 10, 2017 4:59 pm

Hi,

I'm picking sprite with boo var. boo is set to inform weather sprite is free to pick or not. However sometimes i have more then one sprite free to pick, and picking by comparison picks all of them. I tired fixing this with trigger once, but it doesn't seam to help. Any suggestions welcome. Also, if anyone knows how to do "on picking failed", so I can do another action if there are none sprites to pick that would be ace. Cheers
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
89
S
29
G
22
Posts: 1,984
Reputation: 19,997

Post » Mon Jul 10, 2017 5:31 pm

When no sprites are picked at all, an else will trigger (it's actually the only time you want to use else with a picking condition).

As for you first issue, try adding a condition system: pick Nth instance or pick random instance depending on your need after your conditions.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Mon Jul 10, 2017 6:05 pm

One idea : instead of having a boolean, you could have an instance variable "ID" and a global variable "NumberOfInstancesAvailable". When a new instance is available, ,you attribute the value "NumberOfInstancesAvailable"+1 to the ID and then you add 1 to NumberOfInstancesAvailable.
When you pick an instance, instead of checking all instances with boolean set to true, you pick the instance which ID is such that ID=NumberOfInstancesAvailable and you substract one to NumberOfInstancesAvailable.
B
6
S
1
Posts: 29
Reputation: 408

Post » Mon Jul 10, 2017 6:06 pm

I hadn't seen the post of aphrodite. I didn't know these commands, it looks great :)
B
6
S
1
Posts: 29
Reputation: 408

Post » Wed Jul 12, 2017 6:57 pm

Aphrodite wrote:When no sprites are picked at all, an else will trigger (it's actually the only time you want to use else with a picking condition).

As for you first issue, try adding a condition system: pick Nth instance or pick random instance depending on your need after your conditions.


Hi,

So you're saying that my event should look like more like this: Sprite.BooIsAvaible = 1, Pick Nth instance of the sprite? Will it only pick one instance and move on, or will it pick all nth instances? I'll check that out.

@conker23 I tried similar approach, but it didn't work. I might look in to it again and try different approach if Aphrodites way won't work.
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
89
S
29
G
22
Posts: 1,984
Reputation: 19,997

Post » Wed Jul 12, 2017 7:25 pm

pick Nth imstance will pick the nth instance (1st or 2nd or 3rd or 4th etc...) not multiple instances AFAIK
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Wed Jul 12, 2017 7:29 pm

Aphrodite wrote:pick Nth imstance will pick the nth instance (1st or 2nd or 3rd or 4th etc...) not multiple instances AFAIK


Sweet, thx
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
89
S
29
G
22
Posts: 1,984
Reputation: 19,997

Post » Thu Jul 13, 2017 3:49 pm

Aphrodite wrote:pick Nth imstance will pick the nth instance (1st or 2nd or 3rd or 4th etc...) not multiple instances AFAIK


Yo, any clue how can I use that nth instance picking without knowing IID? Or get IID of one object from many that have boo set true.
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
89
S
29
G
22
Posts: 1,984
Reputation: 19,997

Post » Thu Jul 13, 2017 4:45 pm

Sprite > Boolean=true.
Pick sprite nth instance 0.

You now have the sprite where Boolean=true with the lowest IID. Sprite.IID in actions is now the IID of the picked sprite so it's knowable.
B
46
S
16
G
73
Posts: 2,088
Reputation: 43,685

Post » Thu Jul 13, 2017 5:18 pm

plinkie wrote:Sprite > Boolean=true.
Pick sprite nth instance 0.

You now have the sprite where Boolean=true with the lowest IID. Sprite.IID in actions is now the IID of the picked sprite so it's knowable.


Ah man, gotch ya. So it is 0 based index of picked sprites and not of all sprites IID's, correct? And thx. Althought. literaly the moment you wrote your post, I've changed from reusing existing sprite in to destroying and creating them. And it worked. After seeing your post I've fixed the reusing sprites events, and they work too. Interestingly, I don't see any difference in performance between both ways ( thought at first glance I'm leaning towards spawn/destroy option having better fps). I thought from some old topics, that creating objects is more taxing o the framerate. I guess I'll have to check for average fpx.
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
89
S
29
G
22
Posts: 1,984
Reputation: 19,997

Next

Return to How do I....?

Who is online

Users browsing this forum: darkrealos, Rhindon and 14 guests