This site requires JavaScript, please enable it in your browser!
Greenfoot back
comandodude101
comandodude101 wrote ...

2013/1/1

Why wont this respawn code work?

1
2
3
comandodude101 comandodude101

2013/1/2

#
Ok I fixed the error but I still wont respawn. Why?
vonmeth vonmeth

2013/1/2

#
The section of SWorld code I posted above looked like the part I posted above, and you changed only that section of code I changed ... right?
vonmeth vonmeth

2013/1/2

#
Share your Scenario. Press Ctrl+E. There is a check box that says "Publish source code". Check that box.
comandodude101 comandodude101

2013/1/2

#
ok
comandodude101 comandodude101

2013/1/2

#
It is obby course 2
vonmeth vonmeth

2013/1/2

#
The code to add the lobster is working fine. The problem is is that it is getting respawned on top of a dot which means instant death. The world scrolls, so setting it to one position isn't going to work, you need to set it to a position that is relative to another object (or do something even more trickier, but let us settle setting its spawn and respawn position relative to another object). Make your SWorld code exactly this (just copy and paste over the old code). All I did was make two methods public and removed the code we added.
import greenfoot.*;
import java.util.List;
import java.util.ArrayList;

/**
 * SWorld is a super-class for a scrolling world (horizontal, vertical, or both).<br><br>
 * Author: danpost<br>Version: November 21, 2012 (v1.2)<br><br>
 * To implement this super-class:
 * <l><li>(1) create a sub-class of this class</li>
 * <li>(2) use a <i>super(....)</i> call to one of the constructors in this class</li>
 * <li>(3) create the main actor (one that always stays in view) and call the <i>setMainActor</i> method</li>
 * <li>(4) (optional) set a scrolling background image using a call to <i>setScrollingBackground</i></li></l><br>
 * NOTE: the order of steps above is very important<br><br>
 * There are two methods to add other objects into the world:
 * <l><li>the standard method <i>addObject(Actor, int, int)</i> can be used to add a scrollable actor into the world</li>
 * <li>a secondary method <i>addObject(Actor, int, int, boolean)</i> which is equivalent to the standard method, except
 * that the boolean will indicate the scrollable state of the object.</li></l>
 *
 * The width and height dimensions for both the world and the universe of scenarios with a cell size greater than one 
 * will be raised to the nearest odd values to center the main actor.
 */
public class SWorld extends World
{
    private int scrollingWidth, scrollingHeight; // limits for main actor within universal coordinates
    private int actorMinX, actorMaxX, actorMinY, actorMaxY; // limits for main actor within world coordinates
    private int AMT_X, AMT_Y; // initial scrolled amount
    private int scrollType; // indicates scrolling directions (0=none, 1=horizontal, 2=vertical, 3=both)
    Actor mainActor = null; // the actor that always stays visible
    private List<Actor>genActors = new ArrayList(); // lists all generic scrolling actor objects
    private GreenfootImage background = null;
    
    /**
     * The constructor for a universal scroller.
     * Creates an unbounded world and sets the size of the scrollable area.
     *
     * @param wide the window width
     * @param high the window height
     * @param cellSize the size of each cell
     * @param scrollWide the scrollable width (minimum value is window width)
     * @param scrollHigh the scrollable height (minimum value is window height)
     */
    public SWorld(int wide, int high, int cellSize, int scrollWide, int scrollHigh)
    {
        super(cellSize==1?wide:(wide/2)*2+1, cellSize==1?high:(high/2)*2+1, cellSize, false);
        scrollType=(scrollWide>wide?1:0)+(scrollHigh>high?2:0);
        scrollingWidth=scrollType%2==1?scrollWide:wide;
        scrollingHeight=scrollType/2==1?scrollHigh:high;

    }
    
    /**
     * The constructor for a horizontal (side) scroller.
     * Calls the universal scroller constructor with scrollHigh equal to the window height parameter.
     *
     * @param wide the window width
     * @param high the window height
     * @param cellSize the size of each cell
     * @param scrollWide the scrollable width (minimum value is window width)
     */
    public SWorld(int wide, int high, int cellSize, int scrollWide)
    {
        this(wide, high, cellSize, scrollWide, high);
    }
    
    /**
     * Adds the main actor into the world at the center of the window.<br><br>
     * NOTE: this method must be called prior to calling <i>setScrollingBackground</i>.
     * Sets the range in movement within the window for the actor, and determines the range of horizontal
     * and vertical scrollable movement allowable for the actor.<br><br>
     *
     * @param main the actor that is to always stay in view
     * @param xRange the horizontal range of movement within the window
     * @param yRange the vertical range of movement within the window
     */
    public void setMainActor(Actor main, int xRange, int yRange)
    {
        if (main==null)
        {
            System.out.println("A main actor MUST be supplied.");
            System.out.println("");
            return;
        }
        super.addObject(main, getWidth()/2, getHeight()/2);
        mainActor = main;
        xRange=(int)Math.min(xRange, getWidth());
        yRange=(int)Math.min(yRange, getHeight());
        actorMinX=getWidth()/2-xRange/2;
        actorMaxX=getWidth()/2+xRange/2;
        actorMinY=getHeight()/2-yRange/2;
        actorMaxY=getHeight()/2+yRange/2;
    }
    
    /**
     * Adds a scrolling background to the world; see method description for notes on unwanted results.<br><br>
     * NOTE: for this method to work, the main actor must have previously been set with <i>setMainActor</i>.  The image will then
     * be scaled to the appropriate size.  For a world with a cell-size of one, the width of the image will be equal to the 
     * sum of the scroll width and the window width minus the actor's horizontal range within the window, if it is scrollable 
     * in that direction; the calculation for the height is similar; the image is centered in the scrollable world.
     *
     * @param scrollingBackground the image to be used for the scrolling background of the world
     */
    public void setScrollingBackground(GreenfootImage scrollingBackground)    
    {
        if(mainActor==null)
        {
            System.out.println("'setMainActor' MUST be called prior to calling 'setScrollingBackground'.");
            System.out.println("");
            return;
        }
        background = new GreenfootImage(scrollingBackground);
        background.scale(scrollingWidth*getCellSize(), scrollingHeight*getCellSize());
        scrollBackground();
    }
        
    /**
     * Adds an object into the world, listing it in an the Actor array if it is a scrollable object
     *
     * @param obj the object to add to the world
     * @param xLoc the x-coordinate to place the object
     * @param yLoc the y-coordinate to place the object
     * @param scroller a flag indicating whether this object is of scrollable type or not
     */
    public void addObject(Actor obj, int xLoc, int yLoc, boolean scroller)
    {
        super.addObject(obj, xLoc, yLoc);
        if(scroller) genActors.add(obj);
    }
    
    /**
     * Adds a scrollable object into the world, listing them in the Actor array.
     *
     * @param obj the scrollable object to add to the world
     * @param xLoc the x-coordinate to place the object
     * @param yLoc the y-coordinate to place the object
     */
    public void addObject(Actor obj, int xLoc, int yLoc)
    {
        addObject(obj, xLoc, yLoc, true);
    }
    
    /**
     * Removes an object from the world, re-defining fields as neccessary
     *
     * @param obj the object to be removed from the world
     */
    public void removeObject(Actor obj)
    {
        if(obj==null)return;
        if(obj.equals(mainActor))mainActor=null;
        else genActors.remove(obj);
        super.removeObject(obj);
    }
    
    /**
     * Removes a collection of objects from the world, calling <i>removeObject(Actor)</i> for each one in the list
     *
     * @param objs the collection or list of objects to be removed from the world
     */
    public void removeObjects(List<Actor>objs)
    {
        for(Actor obj:objs)removeObject(obj);
    }
  
    /**
     * Runs the scrolling.
     */
    public void act()
    {
        scrollObjects();
        scrollBackground();

}  

    
    
    /**
     * Scrolls the background image.
     */
    public void scrollBackground()
    {
        if (background==null ) return;
        GreenfootImage image = new GreenfootImage(background);
        image.drawImage(background, (getWidth()*getCellSize()-background.getWidth())/2-AMT_X*getCellSize(),
                                    (getHeight()*getCellSize()-background.getHeight())/2-AMT_Y*getCellSize());
        setBackground(image);
    }
    
    /**
     * Scrolls all scrollable object.  Determines how far outside boundary limits the main actor is, and moves all neccessary
     * objects in the same direction, moving the main actor back within boundary limits.  A background can be
     * made up of scrollable actor object(s) to produce a scrolling background; however, determining intersectors with object
     * will have to include the background object as being one or more of them when using <i>null</i> for the class of intersector.
     */
    public void scrollObjects()
    {
        if (mainActor==null) return;
        // determine how far the main actor is outside its standard window limits
        int dx=0, dy=0;
        if(mainActor.getX()<actorMinX) dx=actorMinX-mainActor.getX();
        if(mainActor.getX()>actorMaxX) dx=actorMaxX-mainActor.getX();
        if(mainActor.getY()<actorMinY) dy=actorMinY-mainActor.getY();
        if(mainActor.getY()>actorMaxY) dy=actorMaxY-mainActor.getY();
        if(dx==0 && dy==0) return; // not outside window limits
        // ** outside standard window limits **
        AMT_X-=dx; AMT_Y-=dy;// track scroll amount
        // move all objects to place main actor back within standard window limits
        mainActor.setLocation(mainActor.getX()+dx, mainActor.getY()+dy);
        for(Object obj : genActors)
        {
            Actor actor=(Actor)obj;
            actor.setLocation(actor.getX()+dx, actor.getY()+dy);
        }
        // determine how far the background is inside the world limits
        dx=0; dy=0;
        if(AMT_X > scrollingWidth/2-getWidth()/2) dx=AMT_X-(scrollingWidth/2-getWidth()/2);
        if(AMT_X < getWidth()/2-scrollingWidth/2) dx=AMT_X-(getWidth()/2-scrollingWidth/2);
        if(AMT_Y > scrollingHeight/2-getHeight()/2) dy=AMT_Y-(scrollingHeight/2-getHeight()/2);
        if(AMT_Y < getHeight()/2-scrollingHeight/2) dy=AMT_Y-(getHeight()/2-scrollingHeight/2);
        if(dx==0 && dy==0) return; // background image covers the world
        // ** background does not completely cover world limits
        AMT_X-=dx; AMT_Y-=dy; // adjust scroll amount
        // move all objects so background covers the world
        mainActor.setLocation(mainActor.getX()+dx, mainActor.getY()+dy);
        for(Object obj : genActors)
        {
            Actor actor=(Actor)obj;
            actor.setLocation(actor.getX()+dx, actor.getY()+dy);
        }
        // determine how far main actor is outside universal limits
        dx=0; dy=0;
        if(mainActor.getX() < 0) dx=0-mainActor.getX();
        if(mainActor.getX() > getWidth()-1) dx=(getWidth()-1)-mainActor.getX();
        if(mainActor.getY() < 0) dy=0-mainActor.getY();
        if(mainActor.getY() > getHeight()-1) dy=(getHeight()-1)-mainActor.getY();
        if(dx==0 && dy==0) return;
        // ** outside universal limits
        // move main actor back within world limits
        mainActor.setLocation(mainActor.getX()+dx, mainActor.getY()+dy);
    }
}
Do the same for MyWorld (copy and paste). We are setting the Lobsters spawn relative to dot3, and overriding the act method from SWorld:
import greenfoot.*;

/**
 * Class MyWorld: sample world to show how to make use of my world super-class SWorld
 */
public class MyWorld extends SWorld
{
    Dot dot3 = new Dot();

    /**
     * Creates a scrolling world using a main actor, a background, some obstacles, and a non-scrolling score.
     */
    public MyWorld()
    {    
        super(900, 400, 1, 1000); // scroll world constructor call; last parameter is scroll width
        // in the following statement, the main actor is placed in the center of the window
        prepare();
        setMainActor(new Lobster(), 250, 300); // the int parameters are centered window x and y ranges
        // to start the main actor elsewhere

        mainActor.setLocation( dot3.getX()+50, dot3.getY()-30);


    }

    public void act()
    {
        scrollObjects();
        scrollBackground();

        if (getObjects(Lobster.class).size() == 0)      
        {    
            setMainActor(new Lobster(), 250, 300);  
            mainActor.setLocation(dot3.getX()+50, dot3.getY()-30);     
        }    

    }  

    /**
     * Prepare the world for the start of the program. That is: create the initial
     * objects and add them to the world.
     */
    private void prepare()
    {
        Dot dot = new Dot();
        addObject(dot, 66, 319);
        Dot dot2 = new Dot();
        addObject(dot2, 64, 346);
        dot2.setLocation(58, 338);
        dot.setLocation(59, 319);

        addObject(dot3, 59, 357);
        Dot dot4 = new Dot();
        addObject(dot4, 62, 383);
        Dot dot5 = new Dot();
        addObject(dot5, 98, 388);
        Dot dot6 = new Dot();
        addObject(dot6, 80, 387);
        Dot dot7 = new Dot();
        addObject(dot7, 125, 388);
        Dot dot8 = new Dot();
        addObject(dot8, 146, 382);
        Dot dot9 = new Dot();
        addObject(dot9, 164, 377);
        Dot dot10 = new Dot();
        addObject(dot10, 169, 356);
        Dot dot11 = new Dot();
        addObject(dot11, 169, 325);
        Dot dot12 = new Dot();
        addObject(dot12, 170, 337);
        Dot dot13 = new Dot();
        addObject(dot13, 172, 301);
        Dot dot14 = new Dot();
        addObject(dot14, 172, 278);
        Dot dot15 = new Dot();
        addObject(dot15, 172, 251);
        Dot dot16 = new Dot();
        addObject(dot16, 178, 230);
        Dot dot17 = new Dot();
        addObject(dot17, 61, 284);
        Dot dot18 = new Dot();
        addObject(dot18, 65, 294);
        Dot dot19 = new Dot();
        addObject(dot19, 72, 259);
        Dot dot20 = new Dot();
        addObject(dot20, 79, 228);
        Dot dot21 = new Dot();
        addObject(dot21, 75, 238);
        Dot dot22 = new Dot();
        addObject(dot22, 80, 207);
        Dot dot23 = new Dot();
        addObject(dot23, 83, 186);
        Dot dot24 = new Dot();
        addObject(dot24, 174, 214);
        Dot dot25 = new Dot();
        addObject(dot25, 168, 195);
        Dot dot26 = new Dot();
        addObject(dot26, 170, 175);
        Dot dot27 = new Dot();
        addObject(dot27, 90, 166);
        Dot dot28 = new Dot();
        addObject(dot28, 171, 147);
        Dot dot29 = new Dot();
        addObject(dot29, 176, 157);
        Dot dot30 = new Dot();
        addObject(dot30, 172, 129);
        Dot dot31 = new Dot();
        addObject(dot31, 95, 145);
        Dot dot32 = new Dot();
        addObject(dot32, 102, 123);
        Dot dot33 = new Dot();
        addObject(dot33, 99, 98);
        dot33.setLocation(96, 98);
        dot32.setLocation(95, 123);
        Dot dot34 = new Dot();
        addObject(dot34, 99, 76);
        Dot dot35 = new Dot();
        addObject(dot35, 105, 54);
        Dot dot36 = new Dot();
        addObject(dot36, 106, 33);
        Dot dot37 = new Dot();
        addObject(dot37, 113, 13);
        Dot dot38 = new Dot();
        addObject(dot38, 138, 12);
        Dot dot39 = new Dot();
        addObject(dot39, 163, 11);
        Dot dot40 = new Dot();
        addObject(dot40, 187, 10);
        Dot dot41 = new Dot();
        addObject(dot41, 210, 8);
        Dot dot42 = new Dot();
        addObject(dot42, 244, 9);
        Dot dot43 = new Dot();
        addObject(dot43, 228, 7);
        Dot dot44 = new Dot();
        addObject(dot44, 273, 6);
        Dot dot45 = new Dot();
        addObject(dot45, 276, 26);
        Dot dot46 = new Dot();
        addObject(dot46, 279, 47);
        Dot dot47 = new Dot();
        addObject(dot47, 282, 75);
        Dot dot48 = new Dot();
        addObject(dot48, 285, 87);
        Dot dot49 = new Dot();
        addObject(dot49, 288, 105);
        Dot dot50 = new Dot();
        addObject(dot50, 289, 127);
        Dot dot51 = new Dot();
        addObject(dot51, 291, 150);
        Dot dot52 = new Dot();
        addObject(dot52, 294, 176);
        Dot dot53 = new Dot();
        addObject(dot53, 188, 128);
        Dot dot54 = new Dot();
        addObject(dot54, 205, 128);
        Dot dot55 = new Dot();
        addObject(dot55, 216, 150);
        Dot dot56 = new Dot();
        addObject(dot56, 218, 170);
        Dot dot57 = new Dot();
        addObject(dot57, 214, 192);
        Dot dot58 = new Dot();
        addObject(dot58, 219, 221);
        Dot dot59 = new Dot();
        addObject(dot59, 223, 249);
        Dot dot60 = new Dot();
        addObject(dot60, 226, 270);
        Dot dot61 = new Dot();
        addObject(dot61, 227, 307);
        Dot dot62 = new Dot();
        addObject(dot62, 230, 282);
        Dot dot63 = new Dot();
        addObject(dot63, 230, 333);
        Dot dot64 = new Dot();
        addObject(dot64, 227, 353);
        Dot dot65 = new Dot();
        addObject(dot65, 228, 374);
        Dot dot66 = new Dot();
        addObject(dot66, 254, 379);
        Dot dot67 = new Dot();
        addObject(dot67, 275, 375);
        Dot dot68 = new Dot();
        addObject(dot68, 303, 370);
        Dot dot69 = new Dot();
        addObject(dot69, 296, 197);
        Dot dot70 = new Dot();
        addObject(dot70, 298, 212);
        Dot dot71 = new Dot();
        addObject(dot71, 298, 226);
        Dot dot72 = new Dot();
        addObject(dot72, 296, 245);
        Dot dot73 = new Dot();
        addObject(dot73, 298, 267);
        dot70.setLocation(301, 212);
        dot72.setLocation(300, 245);
        dot72.setLocation(303, 245);
        dot73.setLocation(304, 267);
        dot71.setLocation(307, 226);
        Dot dot74 = new Dot();
        addObject(dot74, 309, 288);
        Dot dot75 = new Dot();
        addObject(dot75, 314, 304);
        Dot dot76 = new Dot();
        addObject(dot76, 328, 377);
        Dot dot77 = new Dot();
        addObject(dot77, 354, 381);
        Dot dot78 = new Dot();
        addObject(dot78, 336, 300);
        Dot dot79 = new Dot();
        addObject(dot79, 356, 299);
        Dot dot80 = new Dot();
        addObject(dot80, 357, 279);
        Dot dot81 = new Dot();
        addObject(dot81, 361, 259);
        Dot dot82 = new Dot();
        addObject(dot82, 360, 238);
        Dot dot83 = new Dot();
        addObject(dot83, 403, 182);
        Dot dot84 = new Dot();
        addObject(dot84, 382, 184);
        Dot dot85 = new Dot();
        addObject(dot85, 370, 181);
        Dot dot86 = new Dot();
        addObject(dot86, 349, 234);
        Dot dot87 = new Dot();
        addObject(dot87, 329, 233);
        Dot dot88 = new Dot();
        addObject(dot88, 351, 179);
        Dot dot89 = new Dot();
        addObject(dot89, 319, 124);
        Dot dot90 = new Dot();
        addObject(dot90, 347, 124);
        Dot dot91 = new Dot();
        addObject(dot91, 379, 126);
        Dot dot92 = new Dot();
        addObject(dot92, 407, 126);
        dot88.setLocation(355, 179);
        removeObject(dot88);
        dot85.setLocation(370, 178);
        dot85.setLocation(361, 177);
        dot85.setLocation(359, 170);
        dot85.setLocation(358, 171);
        dot84.setLocation(381, 172);
        dot83.setLocation(406, 172);
        dot90.setLocation(347, 110);
        dot89.setLocation(320, 106);
        dot91.setLocation(381, 103);
        dot92.setLocation(410, 105);
        dot90.setLocation(347, 106);
        Dot dot93 = new Dot();
        addObject(dot93, 378, 374);
        Dot dot94 = new Dot();
        addObject(dot94, 402, 375);
        Dot dot95 = new Dot();
        addObject(dot95, 430, 381);
        Dot dot96 = new Dot();
        addObject(dot96, 458, 381);
        Dot dot97 = new Dot();
        addObject(dot97, 461, 356);
        Dot dot98 = new Dot();
        addObject(dot98, 461, 332);
        Dot dot99 = new Dot();
        addObject(dot99, 459, 304);
        Dot dot100 = new Dot();
        addObject(dot100, 462, 286);
        Dot dot101 = new Dot();
        addObject(dot101, 454, 258);
        Dot dot102 = new Dot();
        addObject(dot102, 451, 236);
        Dot dot103 = new Dot();
        addObject(dot103, 447, 207);
        Dot dot104 = new Dot();
        addObject(dot104, 426, 186);
        Dot dot105 = new Dot();
        addObject(dot105, 412, 78);
        Dot dot106 = new Dot();
        addObject(dot106, 415, 48);
        Dot dot107 = new Dot();
        addObject(dot107, 416, 25);
        Dot dot108 = new Dot();
        addObject(dot108, 444, 25);
        Dot dot109 = new Dot();
        addObject(dot109, 473, 25);
        Dot dot110 = new Dot();
        addObject(dot110, 507, 25);
        Dot dot111 = new Dot();
        addObject(dot111, 544, 31);
        Dot dot112 = new Dot();
        addObject(dot112, 466, 190);
        Dot dot113 = new Dot();
        addObject(dot113, 474, 166);
        Dot dot114 = new Dot();
        addObject(dot114, 478, 134);
        Dot dot115 = new Dot();
        addObject(dot115, 484, 93);
        Dot dot116 = new Dot();
        addObject(dot116, 490, 113);
        Dot dot117 = new Dot();
        addObject(dot117, 519, 98);
        Dot dot118 = new Dot();
        addObject(dot118, 503, 97);
        Dot dot119 = new Dot();
        addObject(dot119, 548, 107);
        dot110.setLocation(504, 18);
        dot111.setLocation(540, 16);
        dot109.setLocation(477, 19);
        dot109.setLocation(478, 9);
        dot109.setLocation(476, 9);
        dot109.setLocation(477, 24);
        dot108.setLocation(448, 21);
        dot118.setLocation(542, 131);
        dot117.setLocation(517, 98);
        dot117.setLocation(515, 99);
        dot116.setLocation(482, 110);
        Dot dot120 = new Dot();
        addObject(dot120, 565, 21);
        dot118.setLocation(572, 108);
        Dot dot121 = new Dot();
        addObject(dot121, 591, 20);
        Dot dot122 = new Dot();
        addObject(dot122, 619, 17);
        Dot dot123 = new Dot();
        addObject(dot123, 642, 14);
        Dot dot124 = new Dot();
        addObject(dot124, 665, 14);
        Dot dot125 = new Dot();
        addObject(dot125, 692, 19);
        Dot dot126 = new Dot();
        addObject(dot126, 606, 110);
        Dot dot127 = new Dot();
        addObject(dot127, 594, 106);
        Dot dot128 = new Dot();
        addObject(dot128, 627, 106);
        Dot dot129 = new Dot();
        addObject(dot129, 657, 107);
        Dot dot130 = new Dot();
        addObject(dot130, 678, 101);
        Dot dot131 = new Dot();
        addObject(dot131, 703, 103);
        Dot dot132 = new Dot();
        addObject(dot132, 725, 108);
        Dot dot133 = new Dot();
        addObject(dot133, 746, 108);
        Dot dot134 = new Dot();
        addObject(dot134, 767, 108);
        Dot dot135 = new Dot();
        addObject(dot135, 789, 108);
        Dot dot136 = new Dot();
        addObject(dot136, 892, 6);
        Dot dot137 = new Dot();
        addObject(dot137, 890, 18);
        Dot dot138 = new Dot();
        addObject(dot138, 893, 37);
        Dot dot139 = new Dot();
        addObject(dot139, 891, 54);
        Dot dot140 = new Dot();
        addObject(dot140, 895, 68);
        Dot dot141 = new Dot();
        addObject(dot141, 898, 94);
        Dot dot142 = new Dot();
        addObject(dot142, 894, 118);
        Dot dot143 = new Dot();
        addObject(dot143, 894, 150);
        Dot dot144 = new Dot();
        addObject(dot144, 893, 176);
        Dot dot145 = new Dot();
        addObject(dot145, 894, 207);
        Dot dot146 = new Dot();
        addObject(dot146, 894, 232);
        Dot dot147 = new Dot();
        addObject(dot147, 717, 9);
        Dot dot148 = new Dot();
        addObject(dot148, 748, 8);
        Dot dot149 = new Dot();
        addObject(dot149, 779, 13);
        Dot dot150 = new Dot();
        addObject(dot150, 808, 15);
        Dot dot151 = new Dot();
        addObject(dot151, 837, 6);
        Dot dot152 = new Dot();
        addObject(dot152, 866, 3);
        Dot dot153 = new Dot();
        addObject(dot153, 793, 131);
        dot150.setLocation(809, 15);
        dot149.setLocation(777, 16);
        dot56.setLocation(209, 170);
        dot55.setLocation(206, 149);
        dot58.setLocation(215, 213);
        dot60.setLocation(225, 269);
        dot59.setLocation(215, 236);
        dot62.setLocation(228, 285);
        dot60.setLocation(216, 258);
        dot62.setLocation(223, 280);
        dot62.setLocation(218, 283);
        dot63.setLocation(222, 335);
        dot62.setLocation(215, 282);
        dot63.setLocation(221, 335);
        dot63.setLocation(216, 334);
        dot62.setLocation(213, 277);
        dot62.setLocation(214, 272);
        dot61.setLocation(227, 310);
        dot63.setLocation(214, 330);
        dot62.setLocation(215, 258);
        dot61.setLocation(215, 291);
        dot85.setLocation(786, 296);
        removeObject(dot85);
        dot153.setLocation(870, 231);
        Dot dot154 = new Dot();
        addObject(dot154, 854, 229);
        Dot dot155 = new Dot();
        addObject(dot155, 838, 230);
        Dot dot156 = new Dot();
        addObject(dot156, 819, 231);
        Dot dot157 = new Dot();
        addObject(dot157, 721, 126);
        Dot dot158 = new Dot();
        addObject(dot158, 748, 126);
        Dot dot159 = new Dot();
        addObject(dot159, 777, 122);
        dot159.setLocation(790, 132);
        dot158.setLocation(769, 149);
        dot157.setLocation(752, 151);
        Dot dot160 = new Dot();
        addObject(dot160, 737, 145);
        Dot dot161 = new Dot();
        addObject(dot161, 737, 172);
        Dot dot162 = new Dot();
        addObject(dot162, 737, 200);
        Dot dot163 = new Dot();
        addObject(dot163, 738, 226);
        Dot dot164 = new Dot();
        addObject(dot164, 744, 253);
        dot156.setLocation(823, 232);
        Dot dot165 = new Dot();
        addObject(dot165, 746, 270);
        Dot dot166 = new Dot();
        addObject(dot166, 751, 286);
        Dot dot167 = new Dot();
        addObject(dot167, 760, 308);
        Dot dot168 = new Dot();
        addObject(dot168, 784, 310);
        Dot dot169 = new Dot();
        addObject(dot169, 805, 308);
        Dot dot170 = new Dot();
        addObject(dot170, 807, 325);
        dot170.setLocation(894, 255);
        Dot dot171 = new Dot();
        addObject(dot171, 894, 270);
        Dot dot172 = new Dot();
        addObject(dot172, 897, 286);
        Dot dot173 = new Dot();
        addObject(dot173, 899, 307);
        Dot dot174 = new Dot();
        addObject(dot174, 897, 324);
        Dot dot175 = new Dot();
        addObject(dot175, 895, 347);
        Dot dot176 = new Dot();
        addObject(dot176, 878, 353);
        Dot dot177 = new Dot();
        addObject(dot177, 863, 353);
        dot177.setLocation(894, 365);
        dot177.setLocation(892, 366);
        dot176.setLocation(866, 368);
        Dot dot178 = new Dot();
        addObject(dot178, 846, 357);
        dot178.setLocation(845, 363);
        Dot dot179 = new Dot();
        addObject(dot179, 822, 358);
        dot179.setLocation(821, 363);
        dot179.setLocation(816, 374);
        dot178.setLocation(839, 375);
        Dot dot180 = new Dot();
        addObject(dot180, 799, 373);
        Dot dot181 = new Dot();
        addObject(dot181, 787, 384);
        Dot dot182 = new Dot();
        addObject(dot182, 774, 395);
        Dot dot183 = new Dot();
        addObject(dot183, 756, 390);
        Dot dot184 = new Dot();
        addObject(dot184, 740, 387);
        Dot dot185 = new Dot();
        addObject(dot185, 719, 383);
        Dot dot186 = new Dot();
        addObject(dot186, 695, 379);
        Dot dot187 = new Dot();
        addObject(dot187, 679, 374);
        Dot dot188 = new Dot();
        addObject(dot188, 740, 307);
        Dot dot189 = new Dot();
        addObject(dot189, 724, 302);
        Dot dot190 = new Dot();
        addObject(dot190, 708, 295);
        Dot dot191 = new Dot();
        addObject(dot191, 692, 288);
        Dot dot192 = new Dot();
        addObject(dot192, 691, 271);
        Dot dot193 = new Dot();
        addObject(dot193, 661, 366);
        Dot dot194 = new Dot();
        addObject(dot194, 650, 349);
        Dot dot195 = new Dot();
        addObject(dot195, 646, 327);
        dot195.setLocation(637, 328);
        Dot dot196 = new Dot();
        addObject(dot196, 621, 303);
        Dot dot197 = new Dot();
        addObject(dot197, 618, 286);
        Dot dot198 = new Dot();
        addObject(dot198, 621, 264);
        Dot dot199 = new Dot();
        addObject(dot199, 630, 239);
        Dot dot200 = new Dot();
        addObject(dot200, 610, 237);
        Dot dot201 = new Dot();
        addObject(dot201, 589, 237);
        Dot dot202 = new Dot();
        addObject(dot202, 565, 234);
        Dot dot203 = new Dot();
        addObject(dot203, 560, 269);
        Dot dot204 = new Dot();
        addObject(dot204, 562, 255);
        Dot dot205 = new Dot();
        addObject(dot205, 560, 305);
        Dot dot206 = new Dot();
        addObject(dot206, 558, 286);
        Dot dot207 = new Dot();
        addObject(dot207, 545, 316);
        Dot dot208 = new Dot();
        addObject(dot208, 530, 314);
        Dot dot209 = new Dot();
        addObject(dot209, 505, 315);
        Dot dot210 = new Dot();
        addObject(dot210, 492, 314);
        Dot dot211 = new Dot();
        addObject(dot211, 692, 250);
        Dot dot212 = new Dot();
        addObject(dot212, 688, 227);
        Dot dot213 = new Dot();
        addObject(dot213, 688, 203);
        Dot dot214 = new Dot();
        addObject(dot214, 691, 174);
        Dot dot215 = new Dot();
        addObject(dot215, 670, 168);
        Dot dot216 = new Dot();
        addObject(dot216, 653, 170);
        Dot dot217 = new Dot();
        addObject(dot217, 640, 168);
        Dot dot218 = new Dot();
        addObject(dot218, 621, 163);
        Dot dot219 = new Dot();
        addObject(dot219, 602, 165);
        Dot dot220 = new Dot();
        addObject(dot220, 578, 165);
        Dot dot221 = new Dot();
        addObject(dot221, 555, 165);
        Dot dot222 = new Dot();
        addObject(dot222, 528, 164);
        Dot dot223 = new Dot();
        addObject(dot223, 501, 165);
        dot32.setLocation(85, 119);
        dot31.setLocation(82, 143);
        dot27.setLocation(80, 164);
        dot34.setLocation(90, 76);
        dot34.setLocation(86, 70);
        dot33.setLocation(82, 93);
        dot35.setLocation(94, 47);
        dot21.setLocation(71, 237);
        dot19.setLocation(62, 257);
        dot22.setLocation(74, 201);
        dot192.setLocation(696, 262);
        dot191.setLocation(700, 281);
        dot181.setLocation(787, 391);
        dot181.setLocation(783, 389);
        dot180.setLocation(805, 382);
        dot180.setLocation(805, 385);
        dot179.setLocation(823, 382);
        dot178.setLocation(847, 381);
        dot177.setLocation(893, 368);
        dot177.setLocation(894, 363);
        dot177.setLocation(894, 360);
        dot178.setLocation(845, 378);
        dot177.setLocation(894, 360);
        dot177.setLocation(895, 364);
        dot177.setLocation(890, 367);
        dot178.setLocation(845, 379);
        dot177.setLocation(893, 372);
        dot176.setLocation(869, 381);
        dot62.setLocation(212, 274);
        dot61.setLocation(207, 301);
        dot60.setLocation(210, 256);
        dot59.setLocation(210, 233);
        dot117.setLocation(520, 102);
        dot115.setLocation(497, 100);
        dot92.setLocation(402, 97);
        dot201.setLocation(584, 246);
        dot201.setLocation(584, 246);
        dot200.setLocation(609, 250);
        dot200.setLocation(602, 253);
        removeObject(dot199);
        dot202.setLocation(567, 250);
        dot22.setLocation(71, 201);
        dot21.setLocation(62, 234);
        dot20.setLocation(67, 215);
        dot27.setLocation(76, 162);
        dot23.setLocation(74, 182);
        dot76.setLocation(334, 386);
        dot68.setLocation(299, 383);
        dot68.setLocation(299, 388);
        dot67.setLocation(276, 386);
        dot68.setLocation(305, 388);
        dot86.setLocation(346, 236);
        dot82.setLocation(353, 243);
        dot92.setLocation(400, 97);
        dot91.setLocation(373, 103);
        Grapes grapes = new Grapes();
        addObject(grapes, 506, 235);
        dot84.setLocation(387, 171);
        dot156.setLocation(824, 233);
        dot169.setLocation(801, 308);
    }
}
comandodude101 comandodude101

2013/1/2

#
Ok it worked for SWorld but in MyWorld on line 43 it said that a class, interface, or enum was expected. Any idea how to fix that?
danpost danpost

2013/1/2

#
That error is usually due to mismatched brackets. You probably messed them up when working with the 'act' method.
danpost danpost

2013/1/2

#
I believe that instead of changing the 'SWorld' code, the 'act' method of 'MyWorld' could just call 'super.act();'. I will test it out (though I do believe it would work) and then update the Scrolling SuperWorld scenario with information on that point.
vonmeth vonmeth

2013/1/2

#
Oooh, ya, that would work. Thanks danpost. =)
comandodude101 comandodude101

2013/1/2

#
so where should I type the code and what should I type?
comandodude101 comandodude101

2013/1/2

#
Ok I used the code vonmeth gave me and I fixed the initial error but now when I compile the entire game I get a terminal screen that says "actor not in world"
vonmeth vonmeth

2013/1/2

#
You need to copy and paste what I typed for MyWorld. I changed how dot2 is created, and if you didn't change what I changed in the prepare() method, you are going to get that error.
comandodude101 comandodude101

2013/1/2

#
oh ok ill try that
vonmeth vonmeth

2013/1/2

#
Sorry, I meant dot3.
There are more replies on the next page.
1
2
3