Multiply enemies with the same instances

Get help using Construct 2

Post » Wed Oct 09, 2013 11:01 pm

Hello C2 community...

I have another issue, hopefully I can explain this correctly;

I do not want to respawn enemies for my "platform" game... I followed the manual's instruction:

"Object instances are the actual objects you see in a game: an instance of an object type. For example, if there are four TrollEnemys in a layout, those are four instances of the TrollEnemy object type.

It is instances which have a position, angle and size in the layout. Object types do not have these properties - they simply define a 'class' of object."

So according to this logic, I'm assuming if I place all my enemy sprites and "box" (referencing the manual again by placing an invisible box on the layout and adding a pin for the enemy sprite) I'd have to use the event sheet to manage each enemy individually so I don't destroy the first "trollenemy" and in the process destroy all the other trollenemies... Now my problem is how would I go about coding this? In the event sheet I mean, not JDK...
Image
B
35
S
17
G
9
Posts: 103
Reputation: 8,131

Post » Fri Oct 11, 2013 3:27 pm

Yeah there are a few Snafu's like this.

Use the Containers for the sprite and the sprites "trolly" they will spawn and destroy in sets.
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Post » Fri Oct 11, 2013 10:09 pm

@jojoe

Thank you for the reply! Someone else suggested this to me last night(I live in the states) but there's a problem with said "trolly" box sprite(s)... The box sprites "do not" have a "UID"(or at least I did not see it in the property bar) so when I select the "box" sprite on the layout, It automatically selects the multiply "trolly" box sprites at the same time... So how would using containers fix this??? I tried finding something on containers last night(via the manual) and I did not get much information on how to use it for what I want to achieve... An explanation could seriously help me out... Sorry , but I can't upload a capx file to further help explain my dilemma...
Image
B
35
S
17
G
9
Posts: 103
Reputation: 8,131

Post » Fri Oct 11, 2013 10:13 pm

Not sure exactly what you are trying to do.

You can use collision-overlaping to select which it is overlapping. You can also anso do a "select nearest"
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Post » Fri Oct 11, 2013 10:31 pm

Ahh... Selecting nearest may work, but it seem that no one is getting what I'm trying to accomplish... I'm creating a "platform" game... all my enemy sprites have "boxes" attached, or pinned for platform movement (enemy sprite box has the platform behavior attached to them) "Select nearest" would most certainly work if all I had on screen were just instances of the enemy sprites... But since I'm using "platform mechanics" I had to pin the "invisible box sprite" to each enemy object type(I have two different enemy object types in my game so far)... So that's the issue... I mean I could just delete the invisible box and take my chances with the collision detection upon start of layout, but if I can use the invisible boxes for all my enemies, I rather do that instead... The walking animation of my enemies will suffer but I think I could fix that with events(like setting the X and Y position of all the enemies)... I hope this fully explains things @jojoe
Image
B
35
S
17
G
9
Posts: 103
Reputation: 8,131

Post » Sat Oct 12, 2013 12:32 am

See if this helps:

PinSample.capx

Containers actually don't work well if the elements are already in the layout as you aren't guaranteed to get them in the right order. This does the same thing manually. Very little extra code is actually needed.
ImageImageImage
B
71
S
21
G
231
Posts: 3,688
Reputation: 129,352

Post » Sat Oct 12, 2013 1:34 am

@BlACKMASKCEO
If I understand you right it can be done without containers pretty simply. You could also add families to the concept allowing you to use any number of enemies with no extra events.
here is an example.
Example CAPX
Example DEMO
Pic of the important events.



[Edit] I made my example File to slow. looks like @blackhornet pretty much answered it the same way. only difference is I used Pin.PinnedUID and stuck in all in familes. But it's the same idea.onzephyr2013-10-12 01:39:56
B
87
S
14
G
9
Posts: 101
Reputation: 9,937

Post » Sat Oct 12, 2013 2:59 pm

@blackhornet @onzephyr

THANK YOU SO MUCH GUYS!!! Appreciate the example capx files too... I wish I didn't delete the code I had already but it's a small inconvenience to recreate it... I'll apply what I've learned from the example(s)... Again thank you for the replies and uploads
Image
B
35
S
17
G
9
Posts: 103
Reputation: 8,131

Post » Sat Oct 12, 2013 6:27 pm

Oh! I see what you are trying to do now @@BlACKMASKCEO.

You can do that with 1 block like this:



here is a file you can try to test it:

https://docs.google.com/file/d/0B7p8-X5UMeryS1hObGRGWVZxVWs/edit?usp=sharing

I really wish Scirra would add a "ON destroy Kill children" to the pin behaviour.

Doing all this elaborate testing for a simple task like this is really asinine.jojoe2013-10-12 18:31:21
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Post » Sat Oct 12, 2013 6:54 pm

@jojoe....

Dude, I TOTALLY agree with your observation... It's great that the system object is as accessible as it is, but the most "rudimentary" features of programming should be(in theory anyway) fairly straightforward to understand so that execution isn't a tall task for a beginner...

Appreciate the link btw
Image
B
35
S
17
G
9
Posts: 103
Reputation: 8,131

Next

Return to How do I....?

Who is online

Users browsing this forum: AndreasR and 17 guests