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

2014/5/1

Selecting characters and switching them with others

1
2
3
4
5
6
7
danpost danpost

2014/5/2

#
Did you check to see if it was still a PIP actor (right-click on it and select 'Inspect' and post what the title line says).
danpost danpost

2014/5/2

#
Ok. I got it. You can delete it now, if you want.
Zzimon Zzimon

2014/5/2

#
delete what?
danpost danpost

2014/5/2

#
Zzimon wrote...
delete what?
The uploaded scenario from the site.
Zzimon Zzimon

2014/5/2

#
Ok, I'll go ahead and do that then ;)
danpost danpost

2014/5/2

#
It appears you have set the Bejeweled_World world as the start-up world. Your Major world is not what you are looking at. You need to right-click on the Major world icon and select 'new Major()'. I am getting java heap space issues when I try to set that world as the default (start-up) world. It is an extremely large world. I myself try to keep my world to not much more than 1000 x 600. You Major world is about three times that size.
Zzimon Zzimon

2014/5/2

#
Oh, thanks for that, I had that problem on my laptop while trying it out at school today but I didn't really know what it meant, haven't really tried programming on my desktop but now I know to look out for that, thanks!
Zzimon Zzimon

2014/5/2

#
As it is now if I export it as an executable file will the heap space issues still be a problem on other systems?
Zzimon Zzimon

2014/5/2

#
Ok, now the background's fixed, I tried running it and clicking on the bejeweled PIP object but then I get the error message 'java.lang.IndexOutOfBoundsException: Index: 0, Size: 0' what does this entail?
danpost danpost

2014/5/2

#
It means the 'act' method in the Major class has a major problem and it needs to be changed to this:
public void act()
{
    if (Greenfoot.mouseClicked(pip))
    {
        MouseInfo mouse = Greenfoot.getMouseInfo();
        if (mouse == null) return;
        int x = (mouse.getX()-(pip.getX()-minor.getWidth()*minor.getCellSize()/2))/minor.getCellSize();
        int y = (mouse.getY()-(pip.getY()-minor.getHeight()*minor.getCellSize()/2))/minor.getCellSize();
        Tile.setSelected((Tile)minor.getObjectsAt(x, y, Tile.class).get(0));
    }
}
Zzimon Zzimon

2014/5/2

#
Ok, awesome now that works, on to the next step which is telling the Bejeweled_World where we clicked right?
danpost wrote...
(3) inform the Bejeweled_World world which tile was selected
Edit: for clarity.
danpost danpost

2014/5/2

#
Zzimon wrote...
Ok, awesome now that works, on to the next step which is telling the Bejeweled_World where we clicked right?
danpost wrote...
(3) inform the Bejeweled_World world which tile was selected
Edit: for clarity.
Is not that the thing we just did?
Zzimon Zzimon

2014/5/2

#
Well yeah I guess we did but don't we still need the Bejeweled_World to understand it? I mean the Bejeweled_World still needs something to receive the information doesn't it?
danpost danpost

2014/5/2

#
Line 9 in the act method above informs the Tile class which tile was selected. Now we can add an act method to the Tile class to detect keystrokes and to let the Bejeweled_World world know that a move has been selected.
Zzimon Zzimon

2014/5/2

#
Ok so now we have to fix the tile actor so it knows the keystrokes w,a,s and d to move the tiles. I made a little attempt at this, of course this is just a little thought thingy since I don't know the code but this is my little attempt.
        if (tile = selected && Greenfoot.isKeyDown("w"))
        {
            setLocation(getX(), getY() - 1);
            tile = unselected;
        }
EDIT: ok, I don't know how to implement the selected thing properly, tried a few ways now, could you please show me ^^'
There are more replies on the next page.
1
2
3
4
5
6
7