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

2019/3/18

Greenfoot debugger when adding sound

Erasedsword Erasedsword

2019/3/18

#
Hi I'm new to programing in general, i understand the concepts of it, and I'm working on a game for class. when i try to add sound to my title screen the greenfoot debugger keeps popping up and i have no idea why. I am currently using version 2.4.2 as i am unable to receive any newer updates on my computer. it would be greatly appreciated off you can respond to this by the 21st of this month, because thats when this project is due
Super_Hippo Super_Hippo

2019/3/18

#
It would probably help if you show the code you use related to the sound.
danpost danpost

2019/3/18

#
Super_Hippo wrote...
It would probably help if you show the code you use related to the sound.
... plus give what error message exactly you are getting.
Erasedsword Erasedsword

2019/3/18

#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
private GreenfootSound theme = new GreenfootSound("TitleTheme.wav");
 
   /**
    * Constructor for objects of class title.
    */
   public Title()
   {   
       // Create a new world with 600x400 cells with a cell size of 1x1 pixels.
       super(600, 400, 1);
       text();
   }
 
   public void started()
   {
       theme.playLoop();
   }
    
   /**
    * shows text and creates images for title screen at the begining
    */
   private void text()
   {
       showText("Bot", 300,175);
       showText("Attack", 300, 200);
       showText("Press Space To Start", 300, 300);
       showText("Press Enter To Learn How To Play", 300,330);
   }  
 
   /**
    * Changes screed depending on which key is pressed
    */
   public void changeWorlds()
   {
       Space space = new Space();
       Info info = new Info();
       if (Greenfoot.isKeyDown("space"))
       {
           theme.stop();
           Greenfoot.setWorld(space);
       }
 
       if (Greenfoot.isKeyDown("enter"))
       {
           Greenfoot.setWorld(info);
       }
   }
it first started opening when i added the variable for Greenfoot Sound
Erasedsword Erasedsword

2019/3/18

#
this is in a world class titled Title, and info and space are two other world classes
Erasedsword Erasedsword

2019/3/19

#
its not giving me an error message as well. whenever i run the program it stops and pulls up the debugger, which is showing all the variables for an order sequence for space <int>, Title.changeWorlds, and Title.act. it also displays if clicked on one of these sequences the variables called in each class.
danpost danpost

2019/3/19

#
Erasedsword wrote...
its not giving me an error message as well. whenever i run the program it stops and pulls up the debugger, which is showing all the variables for an order sequence for space <int>, Title.changeWorlds, and Title.act. it also displays if clicked on one of these sequences the variables called in each class.
You will need to show your space class codes for review (that is where the error occurred, from what you said here).
Erasedsword Erasedsword

2019/3/19

#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
    //respawn timer
    private int hpt;
    //damage to ship
    private int damageS = 1;
    //damage to enemy
    private int damageE = 1 ;
    //total enemy health
    private int hpE = 5;
    //total ship Health
    private int hpS = 3;
    //adds points earned
    private int score;
    //keeper of total score
    private int Tscore;
    //timerfor testing
    private int timert;
 
    private GreenfootSound music = new GreenfootSound("Think Fast.wav");
 
    public void started()
    {
        music.playLoop();
    }
 
    /**
     * Constructor for objects of class Space.
     *
     */
    public Space()
    {   
        // Create a new world with 600x400 cells with a cell size of 1x1 pixels.
        super(600, 400, 1);
        text();
        prepare();
    }
 
    /**
     * Prepare the world for the start of the program. That is: create the initial
     * objects and add them to the world.
     */
    private void prepare()
    {
        Ship ship = new Ship();
        addObject(ship, 75, 221);
        Enemy enemy = new Enemy();
        addObject(enemy, 563, 215);
    }
 
    /**
     * Respawn Enemy after 250 cycles only if there is no enemys
     */
    public void respawn()
    {
        if (getObjects(Enemy.class).size() !=1)
        {
            hpt++;
            if(hpt ==250)
            {
                addObject(new Enemy(), 563,Greenfoot.getRandomNumber(325)+75);
                hpt =0;
            }
        }
    }
 
    /**
     * returns remaining enemy hp value to remove it if it reaches 0
     */
    public int getHpE()
    {
        hpE = hpE - damageS;
        return hpE;
    }
 
    /**
     * returns remaining ship hp value to remove if it hits 0
     */
    public int getHpS()
    {
        hpS = hpS - damageE;
        return hpS;
    }
 
    /**
     * resets Enemy hp if it reaches 0
     */
    public void changeValue()
    {
        if (hpE <=0)
        {
            hpE = 5;
        }
        respawn();
    }
 
    /**
     * adds score to total points
     */
    public void addScore(int addscore)
    {
        score = score + addscore;
    }
 
    public void text()
    {
        showText("Total score;"+score, 300,30);
        showText("Enemy Health "+ hpE, 500, 30);
        showText("Your Heath "+hpS, 100, 30);
    }
 
    /**
     * changes the enemy values (hp/damage) and displays text
     */
    public void act()
    {
        started();
        text();
    }
}
danpost danpost

2019/3/19

#
Erasedsword wrote...
<< Code Omitted >>
Nothing pops out at me; although, it may have something to do with the music file (as a test, you could try commenting out lines 18 and 22). What does the terminal error say at the top line (it should mention an exception)? Also, what follows at the end of the line with 'space <init>' (should show a number)? Additionally, what line was above the line with 'space <init>'?
Erasedsword Erasedsword

2019/3/19

#
i took a screenshot of the window that keeps opening ill send it over email so you are able to view it . my email is erasedsword@outlook.com
nccb nccb

2019/3/19

#
Is it possible that this is because of a breakpoint? If there is a red stop symbol in the left-hand margin of your editor, Greenfoot will stop there and pull up the debugger. You can click on the symbol to remove it, or restarting Greenfoot will also remove any breakpoints.
Erasedsword Erasedsword

2019/3/19

#
Yes that was it thank you
You need to login to post a reply.