How do I Pick a sprite created in same tick

Get help using Construct 2

Post » Mon Dec 12, 2016 7:04 pm

Hello all!

I'm building a "spawner engine" for creating enemies in my space shooter game where enemies consist of several sprites named "Part" each with their own variables pinned to another sprite object named "host", with other variables.

I need to pick the "part"s after I just created them. It seams, however that they can't be picked. I don't understand that, since I can pick another sprite also just created. The reason I have a hard time working around this is because my spawning system consists of multiple functions that are called in succession and something like a hundred or so variables for everything.
(Individual part size, how connectors are spawned and positioned, animations, and angle for them, several armor, shield and health values, total enemies spawned, and in what formation, their angle and movements, variables to determines behavior for those, weapon position, sizes, numbers, angles, cool-downs, etc. And other stupidly complicated shit for someone like me.)
If I wait 1 tick, for every time this problem occurs, and create a system which goes around this by waiting 1 tick, and then picking these object from some variable I set in order to remember them, the game might be delayed several ticks in total due to this problem occurring multiple times.

I cut down my project extensively to only a few events, in order so illustrate my problem. I would greatly appreciate any feedback any of you :) / :ugeek: / :twisted: might have.

https://drive.google.com/open?id=0B3l68 ... HRxM2MxWUk
B
6
S
2
G
2
Posts: 33
Reputation: 891

Post » Tue Dec 13, 2016 1:02 pm

Iam Sorry but is this what u was looking for ?
https://www.dropbox.com/s/gx3mxk6owekag ... .capx?dl=0
B
30
S
12
G
3
Posts: 6
Reputation: 3,750

Post » Tue Dec 13, 2016 1:17 pm

Good Sir;

Use a container for all the "parts"? They will get created the same time as the sprite.

yours
Winkr7
B
34
S
8
G
3
Posts: 169
Reputation: 3,305

Post » Tue Dec 13, 2016 1:22 pm

You can setup an instance variable right after creating the part with the UID of the created enemy, because the created enemy is in the same pool of objects you're dealing while creating the part.

Example:
On some event condition: System create enemy on layer X at X and Y position;
Create (or make the enemy spawn at any of its reference points) "Hull part 1" at Enemy.X and Y;
Pin "Hull part 1" on Enemy;
Create (or make the enemy spawn at any of its reference points) "Hull part 2" at Enemy.X and Y;
Pin "Hull part 2" on Enemy;


If you're not creating the enemy in the same event, you still able to pick the part and set it to the enemy by conditioning the enemy with something.

An example:
On Enemy Health = 0 (it will pick the enemy destroyed in that moment);
Create Object "Hull with debris" on Enemy.X, Enemy.Y (or make the enemy spawn it at any of its reference points);
Pin Object "Hull with debris" on Enemy;

Or another sample:
On Enemy change animations to "Boss Part 2";
Create Object "Powerful weapons" on Enemy.X, Enemy.Y;
Pin Object "Powerful weapons" on Enemy;
Image
B
108
S
24
G
18
Posts: 1,372
Reputation: 22,817

Post » Tue Dec 13, 2016 2:11 pm

Lets use the tools designed for this.
Containers, timers and booleans.

https://drive.google.com/open?id=0B1SSu ... XVGcEQxMW8





edit: as mentioned above
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Tue Dec 13, 2016 2:47 pm

99Instances2Go wrote:Lets use the tools designed for this.
Containers, timers and booleans.

https://drive.google.com/open?id=0B1SSu ... XVGcEQxMW8





edit: as mentioned above


I explained a complete workaround where he will be able to pick parts at any time.

He containers is nice and only work when he want something spawned and pinned on the creation event, else, you should create and pin in in runtime like I described.

For example, a Player shooting an array and the box is a separated object. If you place it as a container, then, it will spawn with the player and will be shown all the time, while you can create and pin it at runtime and delete it when its usage is finished.

Another example is, what usage have a damaged hull on a brand new enemy? If you use container to spawn the damaged hull, it will be shown on the screen, or you can make it invisible and use the container, but once again, you'll need to pick it and turn it visible, plus, 100 enemies dragging on the screen a sprite object while it's not necessary is a waste of resource and memory (100x updating the position of the invisible damage hull sprite).
Image
B
108
S
24
G
18
Posts: 1,372
Reputation: 22,817

Post » Tue Dec 13, 2016 4:20 pm

I have no idea what you talk about, i talk about a "spawner engine" (as in the question).
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Tue Dec 13, 2016 6:08 pm

@99Instances2Go, I'm talking about the first question and how to pick something spawned whenever you want and not just when creating a new object using containers, because it will not work for everything here need...

He want pick a sprite when desired after spawning it and check the variables inside it, and how to do it is exactly what I have written.

Nifl wrote:I need to pick the "part"s after I just created them. It seams, however that they can't be picked. I don't understand that, since I can pick another sprite also just created. The reason I have a hard time working around this is because my spawning system consists of multiple functions that are called in succession and something like a hundred or so variables for everything.
(Individual part size, how connectors are spawned and positioned, animations, and angle for them, several armor, shield and health values, total enemies spawned, and in what formation, their angle and movements, variables to determines behavior for those, weapon position, sizes, numbers, angles, cool-downs, etc. And other stupidly complicated shit for someone like me.)
Image
B
108
S
24
G
18
Posts: 1,372
Reputation: 22,817

Post » Tue Dec 13, 2016 7:27 pm

The example cant spawn on the click of the mouse or on whatever? The example does not pick newly created objects in the most easy way and in the same tick? Ah ok. No problem. Whatever rocks your click, dude.



Edit; Wait a second. It just dawned to me. You think that i corrected you, because i posted after you.
Not the case, i would have addressed you by name.

I made that capx while you was typing and posting, it will not show your post until i refresh the page.
Upon posting i get noticed, but i post anyway because i put some time in it. After that, i might read whats posted in my 'non-refresh-the-page-time'.

By this, that connection is broken and over whit.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Tue Dec 13, 2016 10:18 pm

No problem. I was working in a sample to update my tutorial and place here a link.

https://www.scirra.com/arcade/tutorial- ... pick-13549
Image
B
108
S
24
G
18
Posts: 1,372
Reputation: 22,817

Next

Return to How do I....?

Who is online

Users browsing this forum: rollyzz, Yahoo [Bot] and 39 guests