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

2017/2/6

@danpost Score switching worlds...

1
2
3
4
Kokoro Kokoro

2017/2/6

#
Ok thanks for the help !! Just update the game with all i request... -Make score transparent -Switch level by score -Make some chasers shoot or just tell me where and how to change it. Thanks again
Kokoro Kokoro

2017/2/6

#
How i can make that 2x cubes "transparent" ? the score one and the kind of attack...?
public void adjustScore(int adjustment)
    {
        score += adjustment; // adjust score
        // adjust score display
        GreenfootImage bg = getBackground();
        bg.setColor(Color.white);
        bg.fillRect(684, 15, 100, 30);
        bg.setColor(Color.black);
        bg.setFont(new Font("SERIF", Font.BOLD, 28));
        bg.setColor(Color.black);
        bg.drawString(""+score, 684, 40);
    }
    
    private void setAction(int action)
    {
        removeObjects(getObjects(Chaser.class)); // remove old chasers
        actionType = action%5; // set bound action
        int[] distances = { 0, 0, -10, 0, -15 }; // bound ranges
        actionDistance = distances[actionType]; // the range for this action
        String[] texts = { "UNBOUND", "LIMIT", "REMOVAL", "WRAPPING", "BOUNCE" }; // the bounds text
        // adjust bounds display
        GreenfootImage bg = getBackground();
        bg.setFont(new Font("SERIF", Font.BOLD, 36));
        bg.setColor(Color.black);
        bg.fillRect(350, 0, 200, 50);
        bg.setColor(Color.gray);
        bg.drawString(texts[actionType], 350, 44);
        // reset score
        score = 0;
        // ensure player is in world
        if (chased.getWorld() == null) addObject(chased, 400, 300);
        
    }
Super_Hippo Super_Hippo

2017/2/6

#
You can create a transparent color like this:
new Color(0, 0, 0, 0);
If you set a transparent color to the image, you can draw with it. Note that if a pixel has a non-transparent color and you draw the transparent color on it, nothing will happen. If you want a color to be semi-transparent, the first three parameters represent the color (e.g. 255, 0, 0 for red) and the last number can be changed to anything between 0 and 255 where 0 is transparent and 255 is on-transparent.
Kokoro Kokoro

2017/2/6

#
I will try..
Kokoro Kokoro

2017/2/6

#
Any help ? @danpost
Super_Hippo Super_Hippo

2017/2/6

#
-Make score transparent
What have you tried now?
-Switch level by score
Insert the world change at X score condition in the adjustScore method after adjusting the score.
-Make some chasers shoot
You can shoot a laser like this:
Laser l = new Laser();
getWorld().addObject(l, getX(), getY());
l.setRotation(getRotation());
Make sure to add an int field which is delaying the shooting (acting like a reload time).
danpost danpost

2017/2/6

#
Kokoro wrote...
How i can make that 2x cubes "transparent" ? the score one and the kind of attack...?
I am not quite sure I understand what you are trying to say. Are you trying to get rid of the score and attack text that is on the background image of the world?
Super_Hippo Super_Hippo

2017/2/6

#
I just noticed danpost already gave you this code, too. I am not sure what you are having trouble right now then.
Kokoro Kokoro

2017/2/6

#
I want to make an "Chaser" just shoot the "Chased" and at the scoreboard you need to to something like.. Remove that 2 block black/white
Kokoro Kokoro

2017/2/6

#
photo link http://imgur.com/a/S93Uk
Kokoro Kokoro

2017/2/6

#
and yes @danpost i want get rid of the boxes that are in back of the text of the score and edge action..
Super_Hippo Super_Hippo

2017/2/6

#
With the code shown above, you are drawing these "boxes". If you understand what the lines of code do, you will see where it is drawn. Just remove the lines and the boxes will disappear.
Kokoro Kokoro

2017/2/6

#
If i do that the 0 will remain and if is it to change it will like one in other.... Also if i do that for the EDGE action it will go way worst like background box will stay in face of text..
Super_Hippo Super_Hippo

2017/2/6

#
What did you think you had to remove?
danpost danpost

2017/2/6

#
I had a simple background image that was entirely black. You, on the other hand, are using some designed pattern which can not so easily be restored (not by simply repainting with a simple color). With the design pattern and because you have other text that needs to remain on the background image, you will need to make a copy image of the area before drawing any text at those location so that you can redraw the image before drawing the new text. This will have to be done in your world constructor using two fields to retain those images:
// with the following fields:
private GreenfootImage scoreTextArea;
private GreenfootImage edgeTextArea;

// in the constructor:
scoreTextArea = new GreenfootImage(100, 30);
scoreTextArea.drawImage(getBackground(), -684, -15);
edgeTextArea = new GreenfootImage(200, 50);
edgeTextArea.drawImage(getBackground(), -350, 0);

// now you can replace lines 6 through 7 above with:
bg.drawImage(scoreTextArea, 684, 15);

// and replace lines 24 through 25 with
bg.drawImage(edgeTextArea, 350, 0);
As long as you have not change the location of the texts as shown above, I believe that should work.
There are more replies on the next page.
1
2
3
4