ND is the name of the class, i want to create an object from, and NDdum is the class this method is located. So I want to create a new object, from an another class, at the same spot. Press control+space, Then begin typing 'get' and it should display info for that method Alternatively, you could notice what type getObjects (Class) returns (->List), then googling 'java api List', should be the first link, scroll down to the method summary section, then find your. If(coin.getClass(). Create a new object from a different class Bassusour Hi again. int points ( (Robson) getWorld ().getObjects (Robson.class). GetWorld().addObject(havecoin, 300, 300) To simplify, you can replace lines 4 and 5 with: getImage ().fill () TNesler. A new GreenfootImage object initially has black set as its drawing color. private static boolean isCrankTurned=false Īctor havecoin = new Message("Its a penny") The color black is referenced by: Color black Color.BLACK It is part of greenfoot's Color class, not its Greenfoot class. * the 'Act' or 'Run' button gets pressed in the environment. Basically in the game there is a character and there's a score count and timer, I want it that as it's trying to state above that when the timer reaches 700 the character 'transforms' into another class for the rest of the timer until the game over happens. * Act - do whatever the Inspector wants to do. * Write a description of class Inspector here. Import greenfoot.* // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) Act order is specified by class: objects of one class will always act before objects of some other class. The Timer class would look something like this: Set the act order of objects in the world. You would add an instance field to the Timer class to hold a PlayWorld object and add an argument to the Timer constructor to pass the PlayWorld object to it. Let us say your world class is called 'PlayWorld' that the method is in. Because the timer is not added to the world, it needs to be 'given' the world object. Now, you want that timer object you created to, let us say, call a method in your world class that ends the game playing time and shows a final score screen. For example, let us say you had a Timer class and create a timer object that you do not place in the world (in fact, if you never add any Timer objects into the world, you should probably drop the 'extends Actor' part of the class declaration statement). Then you would not use 'getWorld()' but the reference given. Really, the only issue is the with the object not placed in the world, there is no reference to the world unless you pass the world object or any actor object that is in that world to the method in question.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |