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
100
S
23
G
38
Posts: 1,873
Reputation: 30,612

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
49
S
18
G
37
Posts: 2,863
Reputation: 26,186

Post » Thu Feb 02, 2012 10:22 pm

Ok i will try this :)
B
100
S
23
G
38
Posts: 1,873
Reputation: 30,612

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
85
S
27
G
77
Posts: 5,000
Reputation: 53,734

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
49
S
18
G
37
Posts: 2,863
Reputation: 26,186

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
85
S
27
G
77
Posts: 5,000
Reputation: 53,734

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
164
S
49
G
123
Posts: 7,778
Reputation: 84,010

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
262
S
93
G
55
Posts: 7,145
Reputation: 67,059

Next

Return to How do I....?

Who is online

Users browsing this forum: GoodCat, lamar and 8 guests