

import {LAYOUT_SIZE} from "@engine/model/impl/ui/generic/container";
import {Game} from "@engine/core/game";
import {Scene} from "@engine/model/impl/scene";
import {Rectangle} from "@engine/model/impl/ui/drawable/rectangle";
import {RenderableModel} from "@engine/model/renderableModel";
import {Color} from "@engine/core/renderer/color";
import {GameObject} from "@engine/model/impl/gameObject";
import {Point2d} from "@engine/core/geometry/point2d";
import {Keyboard} from "@engine/core/control/keyboard";
import {MathEx} from "@engine/core/mathEx";
import {MainView} from "./custom/mainView";
import {Snake} from "./custom/snake"; // todo



export class MainSceneBehaviour {

    game:Game;
    scene:Scene;
    snake:Snake;

    public onCreate(){
        let layoutView = MainView.build(this.game);
        this.scene.getDefaultLayer().appendChild(layoutView);
        //this.scene.getDefaultLayer().findObject({name:'top'}).kill();
        //this.scene.getDefaultLayer().findObject({name:'top'}).moveToFront();
        //(this.scene.getDefaultLayer().findObject({name:'top'}) as GameObject).spriteSheet.alpha = 0.6;
        this.snake = new Snake(this.game,this.scene,layoutView.findObject({id:'mainFrame'}));
    }

    public onUpdate(){
        this.snake.update();
    }


    public onDestroy(){

    }

}
