Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //-----------------------------------------------------------------------------
- // Scene_Base
- //
- // The superclass of all scenes within the game.
- declare class Stage {}
- declare class WindowLayer {}
- declare class ScreenSprite {}
- declare var ImageManager;
- declare var AudioManager;
- declare var SceneManager;
- declare var Graphics;
- declare var $gameParty;
- declare var Scene_Gameover;
- class Scene_Base extends Stage {
- private _active : boolean;
- private _fadeSign : number;
- private _fadeDuration : number;
- private _fadeSprite : any;
- private _windowLayer : any;
- private addChild: any;
- private children: any;
- constructor() {
- super();
- this._active = false;
- this._fadeSign = 0;
- this._fadeDuration = 0;
- this._fadeSprite = null;
- }
- create(){}
- isActive(){
- return this._active;
- }
- isReady(){
- return ImageManager.isReady();
- }
- start(){
- this._active = true;
- }
- update(){
- this.updateFade();
- this.updateChildren();
- AudioManager.checkErrors();
- }
- stop(){
- this._active = false;
- }
- isBusy(){
- return this._fadeDuration > 0;
- }
- terminate(){}
- createWindowLayer(){
- let width = Graphics.boxWidth;
- let height = Graphics.boxHeight;
- let x = (Graphics.width - width) / 2;
- let y = (Graphics.height - height) / 2;
- this._windowLayer = new WindowLayer();
- this._windowLayer.move(x, y, width, height);
- this.addChild(this._windowLayer);
- }
- addWindow(window : any){
- this._windowLayer.addChild(window);
- }
- startFadeIn(duration : any, white? : boolean){
- this.createFadeSprite(white);
- this._fadeSign = 1;
- this._fadeDuration = duration || 30;
- this._fadeSprite.opacity = 255;
- }
- startFadeOut(duration : any, white? : boolean){
- this.createFadeSprite(white);
- this._fadeSign = -1;
- this._fadeDuration = duration || 30;
- this._fadeSprite.opacity = 0;
- }
- createFadeSprite(white? : boolean){
- if(!this._fadeSprite){
- this._fadeSprite = new ScreenSprite();
- }
- if(white){
- this._fadeSprite.setWhite();
- } else {
- this._fadeSprite.setBlack();
- }
- }
- updateFade(){
- if(this._fadeDuration > 0){
- let d = this._fadeDuration;
- if(this._fadeSign > 0){
- this._fadeSprite.opacity -= this._fadeSprite.opacity / d;
- } else {
- this._fadeSprite.opacity += (255 - this._fadeSprite.opacity) / d;
- }
- this._fadeDuration--;
- }
- }
- updateChildren(){
- this.children.forEach(function(child) {
- if(child.update){
- child.update();
- }
- });
- }
- popScene(){
- SceneManager.pop();
- }
- checkGameover(){
- if($gameParty.isAllDead()){
- SceneManager.goto(Scene_Gameover);
- }
- }
- fadeOutAll(){
- let time = this.slowFadeSpeed() / 60;
- AudioManager.fadeOutBgm(time);
- AudioManager.fadeOutBgs(time);
- AudioManager.fadeOutMe(time);
- this.startFadeOut(this.slowFadeSpeed());
- }
- fadeSpeed(){
- return 24;
- }
- slowFadeSpeed(){
- return this.fadeSpeed() * 2;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement