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

2019/6/23

Game stops

EnDronist EnDronist

2019/6/23

#
Why my game stops after start and draw only 1 frame until stop again? In Greenfoot all works correctly. URL: Game
danpost danpost

2019/6/23

#
EnDronist wrote...
Why my game stops after start and draw only 1 frame until stop again? In Greenfoot all works correctly. URL: Game
Unfortunately, with greenfoot using HTML5 and javascript for scenarrios online, you cannot use any part of the java.awt package which you are using in several classes. The same issue goes with the javax.swing package.
EnDronist EnDronist

2019/6/23

#
danpost wrote...
EnDronist wrote...
Why my game stops after start and draw only 1 frame until stop again? In Greenfoot all works correctly. URL: Game
Unfortunately, with greenfoot using HTML5 and javascript for scenarrios online, you cannot use any part of the java.awt package which you are using in several classes. The same issue goes with the javax.swing package.
I commented out all the code associated with java.awt and javax.swing, but the game still stops.
EnDronist EnDronist

2019/6/23

#
Maybe occurs additionally another problem for HTML5?
danpost danpost

2019/6/23

#
Why are you passing consecutive objects of superclasses to objects being created. When you create a PlayerRocket (or any object), you are creating an object that is considered to be of all its superclass types (Rocket, PhysicalObject, Actor and Object). Extending a class gives any object created from the new class ALL the attributes of ALL the classes it extends. You got other crazy stuff going on. I presume x and y are location coordinates (as double types). I have no clue as to what z (as a double type) is. The x and y values can be set when the actor is added to the world -- in the PhysicalObject class:
protected void addedToWorld(World world) {
    this.x = getX();
    this.y = getY();
}
There is no need to pass these values as parameters.
EnDronist EnDronist

2019/6/24

#
danpost wrote...
Why are you passing consecutive objects of superclasses to objects being created. When you create a PlayerRocket (or any object), you are creating an object that is considered to be of all its superclass types (Rocket, PhysicalObject, Actor and Object). Extending a class gives any object created from the new class ALL the attributes of ALL the classes it extends. You got other crazy stuff going on. I presume x and y are location coordinates (as double types). I have no clue as to what z (as a double type) is. The x and y values can be set when the actor is added to the world -- in the PhysicalObject class:
protected void addedToWorld(World world) {
    this.x = getX();
    this.y = getY();
}
There is no need to pass these values as parameters.
I have my own x, y, z coordinates for positioning physical objects in pseudo-3D space. The x, y Actor's values used only for drawing images on screen. Ok, I just add to game description information, that "Game doesn't work in browser, you need to open it in Greenfoot"
You need to login to post a reply.