life variable
#1
Posted 11 March 2012 - 12:16 PM
but when i run the game and i shoot to a spaceship all the spaceship lose life.
how can i fix it?
#2
Posted 11 March 2012 - 12:19 PM
#3
Posted 11 March 2012 - 12:21 PM
The variable is it a local or a global?I'm working now on a space game and i need that each enemy spaceship have their own life variable, so i gave to the obj "speceship" a lifebar.
but when i run the game and i shoot to a spaceship all the spaceship lose life.
how can i fix it?
#4
Posted 11 March 2012 - 06:49 PM
-the first time i put on "create" the icon "set life" to 100 not relative and then i put on draw event the icon "draw life bar" to....
During the game, while there is just one spaceship everything work, but when arrive the second spaceship and i shoot to the first, also the second lose 20 life points
-the second time i put on create a "set variable" icon and i wrote "global.sslife". no draw event.
But again when arrive the second spaceship i shoot to it and both explode...
#5
Posted 11 March 2012 - 07:09 PM
If you are using D&D, you need to put in each ship a trigger for Collision With Bullet (or whatever your weapons are called) and set its life to -20 relative.
#6
Posted 11 March 2012 - 08:40 PM
but if you say that in the pro edition i can do it.. thanx
#7
Posted 11 March 2012 - 09:29 PM
How i can definite a local question (D&D but if you can't, explain me how in gml)
i put in create event set "local.life"
collision event (bullet) set "local.life" relative -2
if "local.life" equal to 0
-start of a block
destroy the istance
-end of a block
but when i run the game appear the messagge "unknow variable"
Why?
#8
Posted 11 March 2012 - 09:34 PM
Creation event:
life = 5; //Example
Collision event with bullet
life -= 2;
if (life <= 0) {
instance_destroy();
}
GameGeisha
#9
Posted 11 March 2012 - 09:44 PM
#10
Posted 12 March 2012 - 01:20 AM
if you're interested in each ship having their own health bar you can put this code in their draw event:
{
draw_sprite_stretched(spr_healthbar1,0,x,y-however-far-above-the-ship,max_life,however-tall-the-bar-is);
draw_sprite_stretched(spr_healthbar1,0,x,y-however-far-above-the-ship,life,however-tall-the-bar-is)
}
sorry if there's a typo i'm doing this off the top of my head.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











