This site requires JavaScript, please enable it in your browser!
Greenfoot back
JackVolp5

JackVolp5

Welcome to my page

JackVolp5's collections

This user has no collections

Recent Comments

Damn I guess I can't do code boxes in comments. RIP.
Yea for sure! So in each of the player classes I have a instance health variable inside a zero-arg constructor. [code] public static int healthP1=100; public player() { healthP1 = 100; } [/code] And every time the bullet intersects with an object of bullet2.class, the yellow bullet, thirty is subtracted from the variable healthP1. [code] public void hitDetection() { Actor d = getOneIntersectingObject(player.class); Actor e = getOneIntersectingObject(Rock.class); Actor f = getOneIntersectingObject(Wagon.class); if(this != null && isAtEdge()) { getWorld().removeObject(this); } else if(d != null) { player.healthP1-=30; getWorld().removeObject(this); } else if(e != null || f != null) { getWorld().removeObject(this); } } [/code] To delete the bullet when it hits the edge, as you can see above, I made a large if/else statement and made sure that if noting else happened to it, it was deleted. If you remove it and then another method or class tries to use it, you will get a null error because it won't exist anymore