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

2013/3/2

Clicking on an object

1
2
3
Gingervitis Gingervitis

2013/3/2

#
So how could I get it to work the text?
Gingervitis Gingervitis

2013/3/2

#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
public void act()
    {
        World world;
        world = getWorld();
        if (world instanceof Intro)
        {
            if (Greenfoot.mouseClicked(this))
            {
                Greenfoot.setWorld(new MainMenu());
            }  
        }
 
        if (Greenfoot.mouseMoved(this)) getImage().setTransparency(0); 
        if (Greenfoot.mouseMoved(null) && !Greenfoot.mouseMoved(this)) getImage().setTransparency(255);
    }
danpost danpost

2013/3/2

#
I asked for the class code (not just the act method). At least show how the image of the object is created and/or set.
Gingervitis Gingervitis

2013/3/2

#
The act method is the only thing in the class. The image is a .png file.
danpost danpost

2013/3/2

#
I do not think this will make any difference; but, it is the only thing that I could think would have the slightest chance of being an issue (inside the class). Rearrange the order of steps in the act method to:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
public void act()
{
    if (Greenfoot.mouseMoved(this)) getImage().setTransparency(0); 
    if (Greenfoot.mouseMoved(null) && !Greenfoot.mouseMoved(this)) getImage().setTransparency(255);
    World world;
    world = getWorld();
    if (world instanceof Intro)
    {
        if (Greenfoot.mouseClicked(this))
        {
            Greenfoot.setWorld(new MainMenu());
        }  
    }
}
Gingervitis Gingervitis

2013/3/2

#
That didn't work.... Would it work if I were to draw the text myself in another program, would it work?
danpost danpost

2013/3/2

#
An image is an image; and not matter what content the image has, if the transparency is set to zero, the image will not be visible. As an option, you can upload the scenario, publishing the source code, so I can take a look at it. I can let you know when I have it, so you can delete it back off the site, is you so desire.
Gingervitis Gingervitis

2013/3/2

#
Ok. It will include the intro to my second Turtle Adventure game. The text will appear at a certain time in the game. There are also delays set so clicking on the object will only work when the turtle is moving.
danpost danpost

2013/3/2

#
OK, I got it. If you wish, you can delete it off the site now.
Gingervitis Gingervitis

2013/3/2

#
While you have the source code can you help with another problem I have?
danpost danpost

2013/3/2

#
The problem is in the Rock class. It is creating multiple Text objects and only the one on top will be set transparent; therefore, making it seem nothing is happening because you still see the Text object behind it.
Gingervitis Gingervitis

2013/3/2

#
How can I fix that then?
Gingervitis Gingervitis

2013/3/2

#
I got it! I set it to eat itself if it sees itself . . . can you help me with another problem I have while you have the source code? When the asteroid falls it gets bigger while the tail shrinks, but I want to make it so the tail grows too but still shrinks. If you see it the way it is, it looks off because the asteroid gets bigger and the tail does not.
danpost danpost

2013/3/2

#
I am still trying to get my head around the way to programmed it so far. The use of the Universal actor seems strange. The logic of the counters in the Rock class needs improved. The initial size of the tail objects can be determined by the current size of the rock. Everything seems to be overly complicated. It would take a lot of work to get things in better form. I am not even sure where to start. I would end up totally re-coding it, probably to the point where it would look foreign to you (instead of the other way around).
Gingervitis Gingervitis

2013/3/2

#
I am just trying to figure out things on my own. I just started Greenfoot in January from a basic computer class ... I used counters because I still don't fully understand boolean statements. Next year i'm taking C++ and Intro to java .... I'm not even in a computer class now.
There are more replies on the next page.
1
2
3