how do i decrease the hp of a single enemie

For questions about using Classic.

Post » Wed Nov 17, 2010 7:31 pm

Hi,
i ve created a global variable that stores the enemies hp and an event which reduces the value on collision with the bullet.
This works great for a single enemy but if i create more then one, hitting a single enemy reduces each ones hp...
How can i fix thix problem? Thanks a lot.. ;=)
B
2
G
2
Posts: 16
Reputation: 682

Post » Wed Nov 17, 2010 7:54 pm

You have to create private var instead of global one for each enemy. than put them in a family and call it trough event.
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
71
S
19
G
19
Posts: 1,919
Reputation: 16,910

Post » Wed Nov 17, 2010 8:03 pm

Do i really have to create a new object for each enemy????
B
2
G
2
Posts: 16
Reputation: 682

Post » Wed Nov 17, 2010 8:14 pm

[quote="kojoma":18hgzyiw]Do i really have to create a new object for each enemy????[/quote:18hgzyiw]

Just do some tutorials ;)
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
71
S
19
G
19
Posts: 1,919
Reputation: 16,910

Post » Wed Nov 17, 2010 8:16 pm

I dint find a solution in any of the tuts...
Please! Yes or no? no, right? ;)
B
2
G
2
Posts: 16
Reputation: 682

Post » Wed Nov 17, 2010 8:17 pm

You can make one object for each TYPE of enemy, with PVs, and a name, then use the Create Object by name to make copies of it at run time for multiple enemies. I'm sure there's other ways to do it too without manually creating a bunch of objects.
B
11
S
2
G
3
Posts: 283
Reputation: 1,968

Post » Wed Nov 17, 2010 8:48 pm

Just add a private variable to the enemy sprite. That way each enemy will have their own hp.
The Ghost Shooter Tutorial covers how to do this.
B
79
S
24
G
54
Posts: 4,744
Reputation: 40,751


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests