![]() ![]() ![]() }If you want to allow the arrow key to be continuously pressed while the spacebar creates multiple bullets (by indivudual presses), the remove the conditions related to the arrows in the first 'if' statement in the act method (in the first code-set, remove the first 'if' block in its entirety and remove any code related to the boolean 'canCreateBullet'). GetWorld().addObject(bullet, getX(), getY()) 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. 3.25 Do this: Open up the Greenfoot API and look in the Greenfoot class under Method and Description for a method that will pause the execution. The method we are looking for is in the Greenfoot class. For your sake, I'll just post the well documented code for you to read. So you can see that Greenfoot has nine classes: Actor, Color, Font, Greenfoot, GreenfootImage, GreenfootSound, MouseInfo, Userinfo, and World. It contains 5 classes named Crab, Lobster, Worm, Counter, and CrabWorld. If (Greenfoot.isKeyDown("up")) arrowsDown++ Every time you eat a worm, the score goes up by 10. In Greenfoot, what type of parameter does the isKeyDown method expect Mark for Review (1) Points Method Integer Boolean String () 6. If (Greenfoot.isKeyDown("left")) arrowsDown++ else if (arrowsDown = 0) dir = 270 Loopy: the 'enter' key is represented by 'enter'. See the documentation for the the Greenfoot class. If (Greenfoot.isKeyDown("down")) arrowsDown++ else if (arrowsDown = 0) dir = 180 However, Java's key handling seems to have changed recently and so this mightn't work properly in the current Greenfoot version I just committed a fix for a future version. If (Greenfoot.isKeyDown("right")) arrowsDown++ else dir = 90 ![]()
0 Comments
Leave a Reply. |