In game i am trying to add a value to an instance variable, but it doesnt working.
here is the link to capx:
instance variable test
My problem is that i want many bombs at the same time, and increase their HP after every 3th destroyed bomb (bomb counter).
I have not looked at your capx but if i undersrtand what your saying then try this:
Global var BombCounter
Global var BombHP // only needs 1 hit
Global var BombTimer[1.0] // add a timer for the bomb so you can increase the timer as the difficulty increases <img src="smileys/smiley1.gif" border="0" align="middle" />
-> System.setVale(BombCounter) // this will benefit you later when you want to restart the game.
-> System.CreateObject([Bomb], random(WindowWidth), -10)) // create a bomb at a random x position, and a y of - 10 so we dont see it spawn
/* Im not sure how your destroying the bombs but i'll pretend there with bullets or something similar */
-> System.createObject([Bullet], Mouse.X, Mouse.Y)
System.CompareVariable(BombHP > 1)
System.CompareVariable(BombCounter > 3)
-> System.setValue(BombCounter) // set it to 0 so we can count again
-> System.SetValue(BombTimer[BombTimer - 0.2) // increase the speed the bombs spawn at
Note, This was rushed and straight out of my head, If you need a example capx let me know
its getting complicated <img src="smileys/smiley4.gif" border="0" align="middle" />
if i declare a global variable for bombs HP then the bombs will share
the same HP if i think right and thats not what i need.
in my final game i will have many types of bombs (with different
properties), when the player goes from one lvl to another i need to
change these properties (instance variables).
question is if i change the instance variable of a given type bomb
then all of his instances will have that HP before hit?
I think what you should do here is keep a global variable BombHP that is the value you'll be modifying over time and that will get affected to the bomb instances on creation.
Based on your original capx
Develop games in your browser. Powerful, performant & highly capable.
so i have to set value for every spawned instance.
nice! <img src="smileys/smiley4.gif" border="0" align="middle" />