-
Notifications
You must be signed in to change notification settings - Fork 3
/
DustExamples.hx
86 lines (74 loc) · 2.6 KB
/
DustExamples.hx
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
package;
import flash.display.StageScaleMode;
import flash.display.StageAlign;
import dust.physics.eg.PhysicsExample;
import dust.systems.SystemMetricsConfig;
import dust.systems.eg.FastInsertionSortAlgorithmExample;
import dust.gui.eg.GUIExample;
import dust.context.DependentConfig;
import dust.mainmenu.MainMenuConfig;
import dust.text.eg.NoScaleBitmapFontExample;
import dust.text.eg.BitmapFontExample;
import dust.text.eg.BitmapTextExample;
import dust.console.ConsoleConfig;
import dust.context.Config;
import dust.interactive.eg.ReflectionDragExample;
import dust.quadtree.eg.QuadTreeVisualizationExample;
import dust.interactive.eg.OffsetDragExample;
import dust.camera.eg.MoveCameraExample;
import dust.interactive.eg.DragExample;
import dust.mainmenu.MainMenu;
import dust.context.Context;
import flash.display.DisplayObjectContainer;
import flash.display.Sprite;
class DustExamples implements DependentConfig
{
static var app:Context;
public static function main()
{
flash.Lib.current.stage.align = StageAlign.TOP_LEFT;
flash.Lib.current.stage.scaleMode = StageScaleMode.NO_SCALE;
app = new Context()
.configure(DustExamples)
.start(new Sprite());
}
@inject public var parent:Context;
@inject public var root:DisplayObjectContainer;
@inject public var mainMenu:MainMenu;
var module:Context;
public function dependencies():Array<Class<Config>>
return [MainMenuConfig];
public function configure()
{
mainMenu
.add("Drag", DragExample)
.add("OffsetDrag", OffsetDragExample)
.add("ReflectionDrag", ReflectionDragExample)
.add("BitmapFont 1", NoScaleBitmapFontExample)
.add("BitmapFont 2", BitmapFontExample)
.add("BitmapText", BitmapTextExample)
.add("QuadTree", QuadTreeVisualizationExample)
.add("GUI", GUIExample)
.add("FastInsertionSort", FastInsertionSortAlgorithmExample)
.add("Physics", PhysicsExample);
root.addChild(mainMenu);
mainMenu.reset.bind(onReset);
mainMenu.selected.bind(onSelection);
mainMenu.enable();
}
function onReset()
{
if (module != null)
module.stop();
module = null;
}
function onSelection(config:Class<Config>)
{
module = new Context(parent)
.configure(MoveCameraExample)
.configure(ConsoleConfig)
.configure(SystemMetricsConfig)
.configure(config)
.start(new Sprite());
}
}