mirror of
https://github.com/photonstorm/phaser
synced 2024-11-24 21:53:59 +00:00
Listen for resize event
This commit is contained in:
parent
9adde867d4
commit
d030e358f0
1 changed files with 20 additions and 0 deletions
|
@ -10,6 +10,7 @@ var ScenePlugin = require('../../../src/plugins/ScenePlugin');
|
|||
var SpineFile = require('./SpineFile');
|
||||
var Spine = require('Spine');
|
||||
var SpineGameObject = require('./gameobject/SpineGameObject');
|
||||
var ResizeEvent = require('../../../src/scale/events/RESIZE_EVENT');
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
|
@ -89,6 +90,10 @@ var SpinePlugin = new Class({
|
|||
this.bootCanvas();
|
||||
}
|
||||
|
||||
this.onResize();
|
||||
|
||||
this.game.scale.on(ResizeEvent, this.onResize, this);
|
||||
|
||||
var eventEmitter = this.systems.events;
|
||||
|
||||
eventEmitter.once('shutdown', this.shutdown, this);
|
||||
|
@ -409,6 +414,21 @@ var SpinePlugin = new Class({
|
|||
return { stateData: stateData, state: state };
|
||||
},
|
||||
|
||||
onResize: function ()
|
||||
{
|
||||
var renderer = this.renderer;
|
||||
var sceneRenderer = this.sceneRenderer;
|
||||
|
||||
var viewportWidth = renderer.width;
|
||||
var viewportHeight = renderer.height;
|
||||
|
||||
sceneRenderer.camera.position.x = viewportWidth / 2;
|
||||
sceneRenderer.camera.position.y = viewportHeight / 2;
|
||||
|
||||
sceneRenderer.camera.viewportWidth = viewportWidth;
|
||||
sceneRenderer.camera.viewportHeight = viewportHeight;
|
||||
},
|
||||
|
||||
/**
|
||||
* The Scene that owns this plugin is shutting down.
|
||||
* We need to kill and reset all internal properties as well as stop listening to Scene events.
|
||||
|
|
Loading…
Reference in a new issue