Add EventBus and GameScene from ecs
This commit is contained in:
55
src/scene/TitleScene.hx
Normal file
55
src/scene/TitleScene.hx
Normal file
@ -0,0 +1,55 @@
|
||||
package scene;
|
||||
|
||||
import scene.WorldMapScene;
|
||||
|
||||
import event.ChangeSceneEvent;
|
||||
|
||||
import components.MenubuttonComponent;
|
||||
|
||||
@:uiComp("heading")
|
||||
class HeadingComp extends h2d.Flow implements h2d.domkit.Object {
|
||||
static var SRC = <heading class="mybox" min-width="200">
|
||||
<text text={"Glass House"}/>
|
||||
for( i in icons )
|
||||
<bitmap src={i} id="icons[]"/>
|
||||
</heading>;
|
||||
|
||||
public function new(icons:Array<h2d.Tile>, ?parent) {
|
||||
super(parent);
|
||||
initComponent();
|
||||
}
|
||||
}
|
||||
|
||||
@:uiComp("title-scene")
|
||||
class TitleScene extends h2d.Flow implements GameScene implements h2d.domkit.Object {
|
||||
static var SRC = <title-scene>
|
||||
<heading([]) id="view"/>
|
||||
<menubutton("New game") public id="btnNewGame"/>
|
||||
<menubutton("Continue game") public id="btnContinueGame"/>
|
||||
<menubutton("Credits") public id="btnCredits"/>
|
||||
<menubutton("Quit") public id="btnQuit"/>
|
||||
</title-scene>;
|
||||
|
||||
public function new(?parent) {
|
||||
super(parent);
|
||||
initComponent();
|
||||
btnNewGame.onClick = function() {
|
||||
Game.current.globalEventBus.publishEvent(new ChangeSceneEvent(new WorldMapScene(Game.current.root)));
|
||||
}
|
||||
btnContinueGame.onClick = function() {
|
||||
btnContinueGame.dom.addClass("highlight");
|
||||
}
|
||||
#if hl
|
||||
btnQuit.onClick = function() {
|
||||
Sys.exit(0);
|
||||
}
|
||||
#else
|
||||
btnQuit.remove();
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
public function getH2dObject() {
|
||||
return this;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user