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

2016/12/7

Adding Objects With an Actor

1
2
HungryHide HungryHide

2016/12/8

#
I really don't understand where it could be. Should I call it from my world 2 or hand class?
danpost danpost

2016/12/8

#
HungryHide wrote...
I really don't understand where it could be. Should I call it from my world 2 or hand class?
Remove the 'lookForFish' method and the call to it from the act method of the Hand class. You only need one object to check for intersecting with the other.
HungryHide HungryHide

2016/12/8

#
Yes, okay. That makes it much more consistent, thanks. Can I trouble you with one more thing? Not really an issue more of a preference.
danpost danpost

2016/12/8

#
HungryHide wrote...
Yes, okay. That makes it much more consistent, thanks. Can I trouble you with one more thing? Not really an issue more of a preference.
Go on.
HungryHide HungryHide

2016/12/8

#
How would I make a start screen rather than just having strings?
danpost danpost

2016/12/8

#
HungryHide wrote...
How would I make a start screen rather than just having strings?
Create a world class for the start screen. Add a 'public void started' method to set a new 'strings' world active. Manually create a new start screen object.
HungryHide HungryHide

2016/12/8

#
@danpost what if I wanted to add instructions to my starting screen?
danpost danpost

2016/12/8

#
HungryHide wrote...
@danpost what if I wanted to add instructions to my starting screen?
Create the image(s) (GreenfootImage objects) with text and draw them onto the background image of the starting screen.
HungryHide HungryHide

2016/12/9

#
It is possible to link a word document I created?
danpost danpost

2016/12/9

#
HungryHide wrote...
It is possible to link a word document I created?
Yes -- well, it would not be linking, but referencing, opening and reading -- but that would take a bit of work to accomplish. Better might be to create an Instructions class:
public abstract class Instructions
{
    public static final String[] LINE =
    {
        "..............."+
        "..............."+
        "..............."
    };
}
Add the non-period characters to all lines in your text document, as above (see lines 5 through 7); then, copy page the entire thing inside the brackets of the array (replacing what I put there, of course). Then you can refer to each line as:
String line1 = Instructions.LINE[0];
String line2 = Instructions.LINE[1];
You do not have to do each line like above -- it was just showing how to reference the lines (look at what is being assigned to the given variables). You can use a loop to iterate through the lines where the loop counter is the index of each line. If all lines are to be centered text, then include "\n" before the ending double quote on each line. That way, you only have to create one image instead of an image for each line. Oh, if you have any blank lines, make sure it has at least one space in it (or add "\n" to it) -- a GreenfootImage cannot be created with zero width.
Nosson1459 Nosson1459

2016/12/9

#
I made a post for first page but I didn't see the second.
danpost danpost

2016/12/9

#
Nosson1459 wrote...
In Hand there is a method looking for Fish, and in Fish there is a method looking for Hand, but only one of those has
World world = getWorld();
world.addObject(new GameOver(), world.getWidth()/2, world.getHeight()/2);
so if the coding for the isTouching is being executed in Hand then the only thing that will happen is it will remove the fish and stop the execution. My suggestion is the you have the isTouching only in Fish (or only in Hand).
@Nosson1459, this was resolved 5 hours and many posts ago.
danpost wrote...
Remove the 'lookForFish' method and the call to it from the act method of the Hand class. You only need one object to check for intersecting with the other.
HungryHide wrote...
Yes, okay. That makes it much more consistent, thanks.
Nosson1459 Nosson1459

2016/12/9

#
That's why I edited my post, because I first didn't see the second page to the discussion.
danpost danpost

2016/12/9

#
Nosson1459 wrote...
That's why I edited my post, because I first didn't see the second page to the discussion.
That has happened before (by others).
Nosson1459 Nosson1459

2016/12/9

#
Similar things have happened to me previously :)
You need to login to post a reply.
1
2