What's the best approach for this?

Get help using Construct 2

Post » Thu Jan 29, 2015 8:12 am

Here's the kind of thing I want to do:

https://www.dropbox.com/s/dath57nh0v8r1fc/SlapJaw_Enemies.jpg?dl=0

I want to make enemies that share a weak spot (or multiple weakspots), a pimple type thing in this case.

Basically I want to be able to design, animate and code one pimple, that can be shot, destroyed etc. Then add it to multiple enemies.

I had thought containers might be the best way to do this, but now that I read about them a little more, it seems that any events that affect one object in a container, will affect them all. This obviously wouldn't work so great for what I need to do.

Also when I create an enemy type, it'd be nice to have the pimples already pinned on to the object in the correct position and angle.

Not too sure where to start.

Thoughts?

Thanks in advance.
B
10
S
4
G
5
Posts: 139
Reputation: 2,983

Post » Thu Jan 29, 2015 8:19 am

I am not sure if my suggestion is the best way but you could have image points to spawn the pimples when you spawn an enemy body. then set a variable that store the UID of the body on the pimple. then some type of condition when a pimple pops with x UID minus hit point from body of same UID. this is a possible solution. :)
B
39
S
11
G
3
Posts: 279
Reputation: 8,446

Post » Thu Jan 29, 2015 8:22 am

Interesting. I haven't messed with UID's too much.

Thanks for the suggestion.
B
10
S
4
G
5
Posts: 139
Reputation: 2,983

Post » Thu Jan 29, 2015 6:27 pm

Anyone else have any methods in mind?

I'm keen to hear a number of approaches, so when I screw one up I have backup :)
B
10
S
4
G
5
Posts: 139
Reputation: 2,983

Post » Thu Jan 29, 2015 9:41 pm

Squeemish wrote:Here's the kind of thing I want to do:

https://www.dropbox.com/s/dath57nh0v8r1fc/SlapJaw_Enemies.jpg?dl=0

I want to make enemies that share a weak spot (or multiple weakspots), a pimple type thing in this case.

Basically I want to be able to design, animate and code one pimple, that can be shot, destroyed etc. Then add it to multiple enemies.

The design and animate part is fine. For the code you probably just need a function to put the code in that can be called easily

I had thought containers might be the best way to do this, but now that I read about them a little more, it seems that any events that affect one object in a container, will affect them all.

Not exactly. All objects in the container will be picked, but it's up to you to do stuff with them, or not. Having said that I still don't think it's the way to go because you can't associate multiple objects of a given type, only one. Maybe look at 3rd party plugins (I'm not sure if InstanceBank is the one).

This obviously wouldn't work so great for what I need to do.

Also when I create an enemy type, it'd be nice to have the pimples already pinned on to the object in the correct position and angle.

You can make this 'automatic' by using OnCreate of the enemy, and just have a Function that you call to add each pimple on an enemy.

But the basic mechanism of storing the UID as suggested earlier is fine, or have an ID for each enemy (more useful IMO as sequential numbering can be used for other things).

B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Fri Jan 30, 2015 5:02 am

In one of my projects, I had an object called "Keypress" that showed an image of a keyboard key to press whenever you approached certain locations/characters.
In the layout, there were multiple instances of the Keypress sprite; each Keypress had an instance variable named "Which."
So, related to KSLR's idea above, say for each enemy you have a pimple, and Pimple.Which is set to the name of the enemy. Whenever Pimple is hit, it calls a function with the value of Which.
PimpleHit("Which") assigns damage wherever you're keeping track of it.
This isn't dissimilar to using the UID, but I find that having a name makes it more human-readable.
B
11
S
4
Posts: 152
Reputation: 1,236

Post » Fri Jan 30, 2015 6:03 am

Nice!

Thanks for the suggestions.

I'll look into all of the approaches and see what works out best.

Appreciate the help!
B
10
S
4
G
5
Posts: 139
Reputation: 2,983


Return to How do I....?

Who is online

Users browsing this forum: blue visionary, OBLIVION and 14 guests