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

2013/12/17

how to let my ship get a crate

2
3
4
5
6
7
8
danpost danpost

2013/12/18

#
Until then.
Super_Hippo Super_Hippo

2013/12/18

#
danpost wrote...
@Super_Hippo, when using the 'Save the world' feature within the Greenfoot application, when you first manually add an object to the world, it codes two lines (one creating the object and the other adding it to the world); and if you then drag that object, it adds another line to set its location. Each time you drag it and 'Save the world' again, another 'setLocation' statement is created. Basically, when manually creating a world, every action you perform is stored and when you 'Save the world', every single action that was recorded is written into your 'prepare' method.
Interesting, I never heard of that feature, but it seems like it produces a lot of useless code.
danpost danpost

2013/12/18

#
Super_Hippo wrote...
Interesting, I never heard of that feature, but it seems like it produces a lot of useless code.
I would suggest to any new programmer not to use this feature more than once or twice; to learn from what code it does create and then start coding it yourself. Most, and certainly not all, scenarios have actors that need to be created and added to the world. How to code this is one of the first things that should be learned when starting out on creating your own scenarios.
virginia001 virginia001

2013/12/19

#
Okay.. lets proceed where we let off, where can i see the size of the image? and for the platform is made bigger after your code should i reset it to my old code when my platforms on both sides are the both size again?
danpost danpost

2013/12/19

#
Add, temporarily, as the last statement in your Platform class constructor ('public Platform()'), the following:
System.out.println("width: "+pImg.getWidth()+"\nheight: "+pImg.getHeight());
Compile and report back the output; then you can remove that temporarily added statement.
virginia001 virginia001

2013/12/19

#
width 107 height 107
danpost danpost

2013/12/19

#
That explains the difference, you overlapped the platform actors to create a larger platform and did not place them side by side. 72*3+107 = 251. Change the platform constructor to this:
public Platform()
{
    GreenfootImage pImg = new GreenfootImage(getImage());
    GreenfootImage image = new GreenfootImage(251, 107);
    for (int n=0; n<4; n++)
    {
        image.drawImage(72*n, 0);
    }
    setImage(image);
}
Report back whether this corrected the change.
virginia001 virginia001

2013/12/19

#
i get this error: no suitable method found for drawImage(int,int) for this method: image.drawImage(72*n, 0);
danpost danpost

2013/12/19

#
Sorry, have trouble with mousepad on laptop sometimes (too sensitive). Correction follows:
public Platform()
{
    GreenfootImage pImg = new GreenfootImage(getImage());
    GreenfootImage image = new GreenfootImage(251, 107);
    for (int n=0; n<4; n++)
    {
        image.drawImage(pImg, 72*n, 0);
    }
    setImage(image);
}
virginia001 virginia001

2013/12/19

#
now the upper platform is a little to wide and the one at the bottom is to small
virginia001 virginia001

2013/12/19

#
when i adjust the (251.107) i change the the both platforms
danpost danpost

2013/12/19

#
Change the code creating and adding the platform objects into the world (lines 16 through 21 in the prepare method, I think) to the following:
Platform platform = new Platform();
addObject(platform, 408, 729);
Platform platform2 = new Platform();
addObject(platform2, 408, 657);
Platform platform3 = new Platform()
addObject(platform3, 408, 585);
The placement needed adjustment because of the size change.
virginia001 virginia001

2013/12/19

#
nope still the same....
danpost danpost

2013/12/19

#
Noticed something, will post again shortly. Do not reply, yet.
danpost danpost

2013/12/19

#
Looking at your original code I see only one large platform; that all 12 of your original platform actors overlapped each other to make one larger platform. However, you keep saying 'both' platforms and even the 3 platforms that I was making would also overlap and create the one larger platform (although not quite placed properly in the world). (1) is there any transparency in the image of the platform (2) is the 'other' platform made up of Platform objects or made from another class (3) am I correct that all 12 of your original platforms created one single large platform
There are more replies on the next page.
2
3
4
5
6
7
8