-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathActionWorld.java
65 lines (54 loc) · 1.59 KB
/
ActionWorld.java
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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import greenfoot.core.WorldHandler;
/**
* Write a description of class ActionWorld here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class ActionWorld extends World
{
/**
* Constructor for objects of class ActionWorld.
*
*/
public ActionWorld()
{
// Create a new world with 672x525 cells with a cell size of 1x1 pixels.
super(672, 525, 1);
SceneManager.getInstance().setActionWorld(this);
//workaround to remove orphan dialogues
final javax.swing.JPanel canvas = WorldHandler.getInstance().getWorldCanvas();
for (java.awt.Component p : canvas.getComponents()) {
canvas.remove(p);
}
Game.setup();
}
public void act() {
super.act();
SceneManager.getInstance().update();
}
public void started() {
super.started();
Game.start();
}
public void stopped() {
Game.pause();
}
public void addObject(Actor object, int x, int y) {
super.addObject(object, x, y);
if (object instanceof Entity) {
SceneManager.getInstance().addEntity((Entity)object);
}
}
public void freeze() {
for(Object character : getObjects(Character.class)) {
((Character)character).freeze();
}
}
public void unfreeze() {
for(Object character : getObjects(Character.class)) {
((Character)character).unfreeze();
}
}
}