Hey everyone
I'm having a bit of trouble getting my health bar to work. What I did is place 10 sprites in my project which are not visible at start. I then placed a counter in game with an initial Value of 10 and an increment of -1. I then placed an EventOnValue in the project which monitors the counter value, continuous detection is enabled and min/max range is set to 0. I then attached the following script to the Counter and EventOnValue.
I also added an EventOnContact and EventOnValue to monitor the collision between the car, the bullets and to run the counter above.
I figure its something wrong with the script since I�m pretty new to it. What happens is this, when I run the game the sprites load up like they are suppose to but 99% of the time the Sprites don't refresh and disappear when my vehicle is hit. It works once every 50 hits id say but it�s random. Anyone have any suggestions as to what I am doing wrong?
Thanks
I'm having a bit of trouble getting my health bar to work. What I did is place 10 sprites in my project which are not visible at start. I then placed a counter in game with an initial Value of 10 and an increment of -1. I then placed an EventOnValue in the project which monitors the counter value, continuous detection is enabled and min/max range is set to 0. I then attached the following script to the Counter and EventOnValue.
Code: [Select]
void Main()
{
if (IN_0 == 1) ///Counter value(Player_Health)
{
iObjectHide(OBJ_44); ///Sprite 1
iObjectHide(OBJ_66); ///Sprite 2
iObjectHide(OBJ_88); ///Sprite 3
iObjectHide(OBJ_110); /// Sprite 4
iObjectHide(OBJ_132); ///Sprite 5
iObjectShow(OBJ_154); ///Sprite 6
iObjectHide(OBJ_176); ///Sprite 7
iObjectHide(OBJ_198); ///Sprite 8
iObjectHide(OBJ_220); /// Sprite 9
iObjectHide(OBJ_242); /// Sprite 10
}
if (IN_0 == 2)
{
iObjectShow(OBJ_44);
iObjectHide(OBJ_66);
iObjectHide(OBJ_88);
iObjectHide(OBJ_110);
iObjectHide(OBJ_132);
iObjectHide(OBJ_154);
iObjectHide(OBJ_176);
iObjectHide(OBJ_198);
iObjectHide(OBJ_220);
iObjectHide(OBJ_242);
}
if (IN_0 == 3)
{
iObjectShow(OBJ_44);
iObjectHide(OBJ_66);
iObjectHide(OBJ_88);
iObjectHide(OBJ_110);
iObjectHide(OBJ_132);
iObjectHide(OBJ_154);
iObjectShow(OBJ_176);
iObjectHide(OBJ_198);
iObjectHide(OBJ_220);
iObjectHide(OBJ_242);
}
if (IN_0 == 4)
{
iObjectShow(OBJ_44);
iObjectShow(OBJ_66);
iObjectHide(OBJ_88);
iObjectHide(OBJ_110);
iObjectHide(OBJ_132);
iObjectHide(OBJ_154);
iObjectHide(OBJ_176);
iObjectHide(OBJ_198);
iObjectHide(OBJ_220);
iObjectHide(OBJ_242);
}
if (IN_0 == 5)
{
iObjectShow(OBJ_44);
iObjectShow(OBJ_66);
iObjectHide(OBJ_88);
iObjectHide(OBJ_110);
iObjectHide(OBJ_132);
iObjectHide(OBJ_154);
iObjectHide(OBJ_176);
iObjectShow(OBJ_198);
iObjectHide(OBJ_220);
iObjectHide(OBJ_242);
}
if (IN_0 == 6)
{
iObjectShow(OBJ_44);
iObjectShow(OBJ_66);
iObjectShow(OBJ_88);
iObjectHide(OBJ_110);
iObjectHide(OBJ_132);
iObjectHide(OBJ_154);
iObjectHide(OBJ_176);
iObjectHide(OBJ_198);
iObjectHide(OBJ_220);
iObjectHide(OBJ_242);
}
if (IN_0 == 7)
{
iObjectShow(OBJ_44);
iObjectShow(OBJ_66);
iObjectShow(OBJ_88);
iObjectHide(OBJ_110);
iObjectHide(OBJ_132);
iObjectHide(OBJ_154);
iObjectHide(OBJ_176);
iObjectHide(OBJ_198);
iObjectShow(OBJ_220);
iObjectHide(OBJ_242);
}
if (IN_0 == 8)
{
iObjectShow(OBJ_44);
iObjectShow(OBJ_66);
iObjectShow(OBJ_88);
iObjectShow(OBJ_110);
iObjectHide(OBJ_132);
iObjectHide(OBJ_154);
iObjectHide(OBJ_176);
iObjectHide(OBJ_198);
iObjectHide(OBJ_220);
iObjectHide(OBJ_242);
}
if (IN_0 == 9)
{
iObjectShow(OBJ_44);
iObjectShow(OBJ_66);
iObjectShow(OBJ_88);
iObjectShow(OBJ_110);
iObjectHide(OBJ_132);
iObjectHide(OBJ_154);
iObjectHide(OBJ_176);
iObjectHide(OBJ_198);
iObjectHide(OBJ_220);
iObjectShow(OBJ_242);
}
if (IN_0 == 10)
{
iObjectShow(OBJ_44);
iObjectShow(OBJ_66);
iObjectShow(OBJ_88);
iObjectShow(OBJ_110);
iObjectShow(OBJ_132);
iObjectHide(OBJ_154);
iObjectHide(OBJ_176);
iObjectHide(OBJ_198);
iObjectHide(OBJ_220);
iObjectHide(OBJ_242);
}
}
I also added an EventOnContact and EventOnValue to monitor the collision between the car, the bullets and to run the counter above.
I figure its something wrong with the script since I�m pretty new to it. What happens is this, when I run the game the sprites load up like they are suppose to but 99% of the time the Sprites don't refresh and disappear when my vehicle is hit. It works once every 50 hits id say but it�s random. Anyone have any suggestions as to what I am doing wrong?
Thanks