If anyone could help me that would be great. The isKeyDown method is a Greenfoot class command, not a command of the Actor or Boat classes, so the word Greenfoot must be typed before it. The boat will turn left only if this is true. So when the lobster that has be added to the world eats the crab, I want that crab to lose a life, but when I try to compile, I get an error on the CrabWorld class that it could not find the method mentioned. The program looks to see if the left key is pressed down. Di Greenfoot, metode mana yang memeriksa apakah kunci pada keyboard telah ditekan > Metode isKeyDown 3. Di Greenfoot Anda dapat berinteraksi dengan skenario menggunakan mouse. Anda hanya dapat menggunakan suara yang disimpan di perpustakaan Greenfoot. If(Greenfoot.getRandomNumber(100)= getWorld().getWidth()-10) Anda tidak dapat merekam suara unik di Greenfoot. * Randomly places worms at random periods It is called isKeyDown, and, like the getRandomNumber method that we encountered in. * Prepare the world for the start of the program. Greenfoot supports the Java Programming Language, so students learn. * Constructor for objects of class CrabWorld. Private Counter score = new Counter("Score: ") * place random worms in the world over time. * Creates the crab Enviornment with a counter, crab and lobster. I need to access the Crab instance (created in the CrabWorld, if that matters) from from the Lobster Class.Ĭrabworld: import greenfoot.* // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) I have tried calling ((CrabWorld) getWorld), but I don't need to access the CrabWorld. This method would change the lives of the crab. But the important part that I am having trouble with is calling a method from the lobster to the Crab instance created by the CrabWorld. For your sake, I'll just post the well documented code for you to read. It contains 5 classes named Crab, Lobster, Worm, Counter, and CrabWorld. Select an image from the Greenfoot library Import an image Correct Correct 1. Every time you eat a worm, the score goes up by 10. There is a lobster that randomly roams around and if comes in contact with the crab, the crab dissapears. I'm makeing a game where you play the crab and move around to collect worms. I have become familiar on how to call certain methods between classes, and also differences between static and non-static. I have just started programming some things with Greenfoot, learning java along the way.
0 Comments
Leave a Reply. |