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

2017/10/15

Help With Title Screen

LlamaDelRay LlamaDelRay

2017/10/15

#
So I'm very new to Greenfoot and such and I'm almost done doing my game but I don't know how to make a Title Screen. I want to be able to make a title screen in which the player is given five buttons. One to start the game, another to start a harder game, one to start a bonus game, and the last two are to show a screen of instructions for the players to know the controls and the other to show credits. My problem is that I don't know how to make the player to click one of the buttons to the specified order they must do. Another problem of mine is that whenever I run my program, it takes like a couple of seconds and immediately goes straight into the game. I need help for this, an anyone help me?
danpost danpost

2017/10/15

#
Please show what code you have for your title screen world.
LlamaDelRay LlamaDelRay

2017/10/15

#
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class StartScreen here. * * @author (your name) * @version (a version number or a date) */ public class StartScreen extends World { private int counter; public StartScreen() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super(25, 25, 20); prepare(); } private void click() { Greenfoot.setWorld(new Maze()); } public void act() { click(); if (Greenfoot.mouseClicked(Start.class)) { if (++counter == 2000) Greenfoot.setWorld(new Maze()); } } /** * Prepare the world for the start of the program. * That is: create the initial objects and add them to the world. */ private void prepare() { Title title2 = new Title(); addObject(title2,18,5); title2.setLocation(16,6); Glommer2 glommer22 = new Glommer2(); addObject(glommer22,5,9); glommer22.setLocation(5,10); Glommer1 glommer12 = new Glommer1(); addObject(glommer12,19,19); StartStatue startstatue2 = new StartStatue(); addObject(startstatue2,6,18); glommer22.setLocation(4,9); glommer22.setLocation(5,10); startstatue2.setLocation(6,18); startstatue2.setLocation(6,18); startstatue2.setLocation(6,18); startstatue2.setLocation(6,18); startstatue2.setLocation(6,18); startstatue2.setLocation(6,18); startstatue2.setLocation(6,18); startstatue2.setLocation(6,18); startstatue2.setLocation(1,23); Start start2 = new Start(); addObject(start2,6,11); start2.setLocation(5,12); Help help2 = new Help(); addObject(help2,19,22); help2.setLocation(19,22); startstatue2.setLocation(5,19); startstatue2.setLocation(6,19); Harder harder2 = new Harder(); addObject(harder2,7,16); harder2.setLocation(6,16); JokeMode jokemode2 = new JokeMode(); addObject(jokemode2,7,19); jokemode2.setLocation(6,19); Credits credits2 = new Credits(); addObject(credits2,8,22); credits2.setLocation(7,22); } }
danpost danpost

2017/10/15

#
Now wonder your Maze world is showing up immediately -- the first thing you are doing in the act method is unconditionally calling 'click'. The rest of the act method does not look so good either -- you would have to click the start button 2000 times before a Maze world is activated.
You need to login to post a reply.