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

2017/1/24

How to make button for change world

Greenboy Greenboy

2017/1/24

#
I want to make button for change map. I have Map1, Map2, Map3, .... I tried to make this:
1
2
3
4
5
6
7
8
9
public static int v= 0;
public void act()
    {
        if(Greenfoot.mouseClicked(this)){
            v++;
         Greenfoot.setWorld(new "Map"+v());
           
        }
    }
Not working :( How to make this?
danpost danpost

2017/1/24

#
You cannot convert a String object into a Type of class. You will need to either use multiple 'if' statements to create the correct type object depending on the value of 'v' or use a 'switch' statement to do similarly.
Greenboy Greenboy

2017/1/25

#
Thanks sir!
You need to login to post a reply.