health bar for each enemy

Get help using Construct 2

Post » Thu Feb 02, 2012 9:09 pm

How do i health bar on top of opponent, i mean health bar for each enemy
B
94
S
19
G
34
Posts: 1,840
Reputation: 27,988

Post » Thu Feb 02, 2012 9:57 pm

You can do it the same way I made the shadows for the coffee beans on the Monjava website I just made:


This should help somewhat, hopefully. I got rid of any events that aren't really important. ;)

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
45
S
17
G
37
Posts: 2,853
Reputation: 25,966

Post » Thu Feb 02, 2012 10:22 pm

Ok i will try this :)
B
94
S
19
G
34
Posts: 1,840
Reputation: 27,988

Post » Thu Feb 02, 2012 11:01 pm

I'd like to point out that you can simplify it by taking advantage of the way events work. When there are an equal number of Bean1's and Bean1shadow's then this will pair them.

Every Tick:
--Bean1shadow| set position to (Bean1.X, Bean1.Y+14)
--Bean1shadow| set angle to Bean1.Angle
B
79
S
24
G
54
Posts: 4,751
Reputation: 40,765

Post » Fri Feb 03, 2012 6:27 am

[QUOTE=R0J0hound] I'd like to point out that you can simplify it by taking advantage of the way events work. When there are an equal number of Bean1's and Bean1shadow's then this will pair them.

Every Tick:
--Bean1shadow| set position to (Bean1.X, Bean1.Y+14)
--Bean1shadow| set angle to Bean1.Angle[/QUOTE]

I actually tried this method, and all shadows went to a single bean.... at least in C2. Lucid wrote me a up a quick pairing example, and it worked awesome :)

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
45
S
17
G
37
Posts: 2,853
Reputation: 25,966

Post » Fri Feb 03, 2012 7:10 pm

It works, here is a example as proof:
http://dl.dropbox.com/u/5426011/examples%209/container.capx

Using the UID instead has certain advantages like when you want a certain object paired with another. My method is if you just need another object type paired up and it doesn't matter if it's always the same one.
B
79
S
24
G
54
Posts: 4,751
Reputation: 40,765

Post » Fri Feb 03, 2012 7:43 pm

Yeah, you could always use the object index as well.
Still, containers are absolutely perfect for this.
Image Image
B
161
S
48
G
91
Posts: 7,358
Reputation: 67,271

Post » Sat Feb 04, 2012 1:28 am

[QUOTE=R0J0hound] It works, here is a example as proof:
http://dl.dropbox.com/u/5426011/examples%209/container.capx[/quote]

It looks like this shouldn't work and yet it does.

In conditions 5/6 you pick the first instance of healthbars / shadows why does this destroy the one that matches the underlying object and not the first instance created ?
B
12
S
3
G
3
Posts: 73
Reputation: 2,647

Post » Mon Feb 06, 2012 8:35 pm

Anyone?
B
12
S
3
G
3
Posts: 73
Reputation: 2,647

Post » Mon Feb 06, 2012 9:10 pm

@R0j0hound or @Ashley probably could give a better explaining.
As far as I can word it, I guess the pairing code Ashley included in C2 makes it so that instances of different objects get associated when created in the same event.
So when you filter Sprite instances (health <=0) and then run through all the instances resulting as picked (for each sprite) in the subevent picking the first instance (index 0) of another object type returns the associated instance with the current sprite instance.

That's surely not clear, I'm sorry I don't know how to word it better for now.

As rojo said, it has to do with how events work and are processed.
One condition after the other from top to bottom and subevents pick up with the instances already filtered from the top level event.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Next

Return to How do I....?

Who is online

Users browsing this forum: DemantDigitalArt, farfetchd83, Google [Bot], mjj1990, spcsmrf and 7 guests