This site requires JavaScript, please enable it in your browser!
Greenfoot back
t_k_990
t_k_990 wrote ...

2017/6/10

Location not found error

t_k_990 t_k_990

2017/6/10

#
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class flowerBlock2 here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class flowerBlock2 extends Actor
{
    /**
     * Act - do whatever the flowerBlock2 wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        CrackedFlower();
        /*if(Rocket.bulletOnScrn = true) {
            Bullet = getOneObjectAtOffset(getX(), getY(), Bullet.class); //gives error that actor not on screen
       }
       else {
           
       }*/
    }
    GreenfootImage img = new GreenfootImage("flower 2 no crack.png");
    GreenfootImage img2 = new GreenfootImage("change flower to png and make crack.png");
    static boolean cracked;
    public static int timesHit = 0;
    public void CrackedFlower() 
    {
        if(Bullet == null && cracked == false) {
            setImage(img);
            if(Bullet != null && !cracked == false) {
                setImage(img2);
                cracked = true;
                timesHit = timesHit +1;
            }
        }
        if(Bullet != null || cracked == true) {
            setImage(img2);
            cracked = true;
            timesHit = timesHit +1;
        }
        if(timesHit >= 2) {
            getWorld().removeObject(this); //still shows error, 1 bullet counts as two shots
        }
    }
    Actor Bullet;

}
This is my code, The error is in line 19
t_k_990 t_k_990

2017/6/10

#
What should I do to fix the error?
Super_Hippo Super_Hippo

2017/6/10

#
I am pretty sure that neither line 18 nor the CrackedFlower method are doing what you want them to do, but for now, try moving line 17 to the end of the act method.
You need to login to post a reply.