I want to add health so I can make it so that if i hit my actor (seal) it would take 3 shots to full kill it.
Im not sure why it wont work, it just adds 100 score every time i hit the seal but it wont die. Do I need to put the code into another class?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | public void Shot() { Actor bullet = getOneObjectAtOffset( 0 , 0 , Bullet. class ); if (bullet != null ) { getWorld().removeObject(bullet); health--; if (health == 0 ){ getWorld().removeObject( this ); World myWorld = getWorld(); SealWorld sealworld = (SealWorld)myWorld; Counter counter = sealworld.getCounter(); counter.addScore( 100 ); } } |