1/21/2024 0 Comments Greenfoot world set text size![]() If a becomes equal to threshold, it will execute RandomPlacement and then set a as 0 again (loop) * Each time an act is happening, one is added to a. * Creates a world with the size of 1100x500 cells, where every cell is just 1 pixel This initializes (gives an initial value) the new object * The operator is followed by a call to a contructor. * It sets a java objerator keyword ( this creates the object) * it declares a variable (so it can be used later in the code) * Counter counter = new Counter() does three things: GreenfootSound backgroundMusic = new GreenfootSound("BACKGROUND.wav") Private int thresholdWave = 3 //increase to make the time until a random thing is added longer. this class will hold the actor for which it will be the selector for, show its image with its name and wait for a click, upon which the new space world will be created, informed of the selection and set active.Private int threshold = 100 //increase to make the time until a random thing is added longer. }If any name is too big and part of it is cut off of the actor image, decrease the '24' on line 11 (go down by twos). L4_SpaceWorld spaceWorld = new L4_SpaceWorld() Image.drawImage(text, 40-text.getWidth()/2, 76) GreenfootImage image = new GreenfootImage(80, 100) GreenfootImage text = new GreenfootImage(actor.getClass().getName(), 24, null, null) GreenfootImage img = new GreenfootImage(actor.getImage()) I do not know if only the images are different for the 5 possible selections or not, so I will add a reference field to hold the actor itself instead of just using the image of the Selector objects created: We will start by making a subclass of actor called 'Selector'. We will address that at the same time as we make it easier to make a simple selection. Now, you also appear to have a problem when your actors are placed in the SelectionWorld world. A second problem with the prepare method is that all 5 actors will be placed at exactly the same location if the method was ever executed Other worlds cannot be objects in that world. The documentation says the method will 'Set the paint order of objects in the world.' The paint order would be specific to world object the method is executed on. No two worlds will ever be active at the same time but the different types of actors in a world is what need attention as far as paint order. (2) you have a prepare method that would set the paint order and add 5 actors into the world if it was ever called problem is that you have World classes in the paint order not actor classes. (1) you have a world constructor that calls 'super' to create the world but that is all the constructor does and there is no act method in the class. Let us start with your SelectionWorld class. PopUpMessage popup = new PopUpMessage(msg) ĪddObject(popup, getWidth() / 2, getHeight() / 2) SuperCandys = getObjects(SuperCandy.class) Private void addRandomSuperCandy(int howMany)ĪddObject(new SuperCandy(), 200 + Greenfoot.getRandomNumber(getWidth() - 200),ġ00 + Greenfoot.getRandomNumber(getHeight()) - 200) SetPaintOrder(CountdownClock.class, Irene.class, Seulgi.class, Wendy.class, Joy.class, Taeyeon.class, * of 900圆00 cells, where every cell is just 1 pixel. Private GreenfootSound backgroundMusic = new GreenfootSound("행복 Happiness.mp3") Import greenfoot.* // (Actor, World, Greenfoot, GreenfootImage) : SelectionWorld cannot be cast to L4_SpaceWorld ![]() So this is the code in the SelectionWorld, also the problem with the objects not appearing. SetPaintOrder(SelectionWorld.class, L4_SpaceWorld.class, LB_HeavenWorld.class) * Prepare the world for the start of the program. ![]() Create a new world with 600x400 cells with a cell size of 1x1 pixels. * Constructor for objects of class SelectionWorld. Public class SelectionWorld extends World * Write a description of class SelectionWorld 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 |