ok i have an apple and the character the character can walk over and touch the apple when he touches it he gets 30 random health but then if he health is already 100 the apple will give him 130. ??? is their any way to make it so his health doesnt go past 100
heres the code on the apple
PHP Code: onClipEvent (enterFrame) { } if (this.hitTest(_root.char)) { _root.hp_bar += 30+random(30); if (_root.hitTest.hp_bar <= 100) } thats my attempt lol
this is bugging me is there anyway i can fix this?
One, you should have your code inside the clipEvent. Second, the second if statement should be directly below the first one or it won't do anything. Third, You shouldn't use hitTest as an instance name as it's reserved in the namespace. Fourth, Your health will always equal one hundred as long as your touching the apple because the first if will be true as long as you touch the apple.