This message comes after hitting the Enemy. Either it has not yet been inserted, or it has been removed.Īt (Actor.java:714)Īt (Actor.java:979)Īt (Simulation.java:567)Īt (Simulation.java:530)Īt (Simulation.java:193)Īt (Simulation.java:183) An attempt was made to use the actor's location while it is not in the world. How do I access an object from another class NB111 8 I want to make it so that if I click on a certain object in the world, then the image for that object changes, however I can't seem to find a way to access the object that's in the world class from my other class. The object was just removed from the world, so it isn't in any world right now. In Greenfoot, this is shown with an arrow in the class diagram. Line 8 does not work because 'getWorld ()' returns null. A.is a class that represents a specialization another. A class contains the code for a specific type of. To remove an object from the world it is currently in, you can simply use this: getWorld ()).removeObject (this) So line 7 works if the object is in a 'Fireplace' world. Public means that it can be accessed by other actors in the game. Normally nothing happens, but sometimes the treminal says:Īva.lang.IllegalStateException: Actor not in world. We declare that Boat is a subclass of Actor. If(isAtEdge() || noob != null || wall!= null)// Verschwindet am Welt ende un beim auftreffen eines NPC When you have got the reference you can easily check where your object is using the getX and getY methods. Therefore you should read this Greenfoot Tutorial. Wall = getOneIntersectingObject(Obstacle.class) To get the coordinates of another object you first have to get a reference to the Robby object. Noob = getOneIntersectingObject(NPC.class) Not sure if this works, but you could try. The other classes belong to the wombat scenario, and will be different if you use different scenarios. ![]() The classes World and Actor will always be there they come with the Greenfoot system. GetImage().scale(getImage().getWidth()/28,getImage().getHeight()/8) Replace ClassOnTop with the class which should be on top of the other one. Here you can see all Java classes that are involved in the project. ![]() * Write a description of class Arrow here. Import greenfoot.* // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |