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

2014/8/3

Passing a boolean value to subclass

2
3
4
5
Super_Hippo Super_Hippo

2014/10/26

#
Could you post the 'createLevel' method in the levelCreator class? I think I don't understand the logic yet.
danpost danpost

2014/10/26

#
Super_Hippo wrote...
What is 'String level = levelCreator.createLevel(levelNumber ++);' supposed to do? The string won't be 'null', so the code there won't be executed.
Evidently, 'levelCreator.createLevel' is a method that returns a string which represents the map of the level number given. Also, 'null' certainly could be the value returned.
I have tryed to set an image wich is an actor but the world has no idea what an image is... is it possible?
If you mean what I think you mean by this, then you just need to add a new instance of that actor class into the world.
elupslin elupslin

2014/10/26

#
Thank you , but i hav an actor with an image ( a message saved as png) the world dont take images in any form i have tryed for exampel Image image= new greenfootImage.... and so on this is the part i am really bad at. And also the class world does not have getImage or setImage...
danpost danpost

2014/10/26

#
If you have an actor class that you have set your png as the default image for, then you do not need to use getImage or setImage and you do not need to work with GreenfootImages either. All you need to do is 'addObject(new Message(), x, y)' -- create a message actor object and add it into the world at the desired location.
elupslin elupslin

2014/10/26

#
I will try! Thank you : )
elupslin elupslin

2014/10/26

#
GREAT!! I did not think it would be this easy : ) But a little problem still, if I want to post it where the girl is, if I for exampel make new levels and the girl will change possision in the end of the level??
danpost danpost

2014/10/26

#
The girls position can be acquired by using 'getX' and 'getY' on a reference to the girl. You can check for edges of world and use offset amounts so that the message is in bounds and not overtop of the girl.
Super_Hippo Super_Hippo

2014/10/26

#
Btw, the World class doesn't support the 'setImage' method. Instead, the method is 'setBackground' which works the same.
elupslin elupslin

2014/10/26

#
Fine! Thank you all,
GreenfootStars GreenfootStars

2014/10/26

#
danpost wrote...
The snippet can be simplified to this:
Actor ground = getOneObjectAtOffset(0, getImage().getHeight()/2 , Platform.class);
if(ground != null && !((Platform)ground).isTransparent())
{ 
    moveOutOfGround(ground);
    onGround = true;       
}
This was great! :) Managed to finish the whole thing. THANK YOU SO MUCH danpost and Super_Hippo! You guys are amazingly awesome and have really saved my ass!
You need to login to post a reply.
2
3
4
5