-
Notifications
You must be signed in to change notification settings - Fork 2
/
layer.js
2 lines (2 loc) · 4.53 KB
/
layer.js
1
2
var gdjs;(function(n){class h{constructor(e,t){this._cameraRotation=0;this._zoomFactor=1;this._timeScale=1;this._defaultZOrder=0;this._rendererEffects={};this._name=e.name,this._hidden=!e.visibility,this._initialEffectsData=e.effects||[],this._cameraX=t.getGame().getGameResolutionWidth()/2,this._cameraY=t.getGame().getGameResolutionHeight()/2,this._cachedGameResolutionWidth=t.getGame().getGameResolutionWidth(),this._cachedGameResolutionHeight=t.getGame().getGameResolutionHeight(),this._runtimeScene=t,this._effectsManager=t.getGame().getEffectsManager(),this._isLightingLayer=e.isLightingLayer,this._followBaseLayerCamera=e.followBaseLayerCamera,this._clearColor=[e.ambientLightColorR/255,e.ambientLightColorG/255,e.ambientLightColorB/255,1],this._renderer=new n.LayerRenderer(this,t.getRenderer()),this.show(!this._hidden);for(let a=0;a<e.effects.length;++a)this.addEffect(e.effects[a])}getRenderer(){return this._renderer}getDefaultZOrder(){return this._defaultZOrder}setDefaultZOrder(e){this._defaultZOrder=e}onGameResolutionResized(){const e=this._cachedGameResolutionWidth,t=this._cachedGameResolutionHeight;this._cachedGameResolutionWidth=this._runtimeScene.getGame().getGameResolutionWidth(),this._cachedGameResolutionHeight=this._runtimeScene.getGame().getGameResolutionHeight(),this._cameraX+=(this._cachedGameResolutionWidth-e)/2,this._cameraY+=(this._cachedGameResolutionHeight-t)/2,this._renderer.updatePosition()}getRuntimeScene(){return this._runtimeScene}updatePreRender(e){this._followBaseLayerCamera&&this.followBaseLayer(),this._renderer.updatePreRender(),this._effectsManager.updatePreRender(this._rendererEffects,this)}getName(){return this._name}getCameraX(e){return this._cameraX}getCameraY(e){return this._cameraY}setCameraX(e,t){this._cameraX=e,this._renderer.updatePosition()}setCameraY(e,t){this._cameraY=e,this._renderer.updatePosition()}getCameraWidth(e){return+this._cachedGameResolutionWidth*1/this._zoomFactor}getCameraHeight(e){return+this._cachedGameResolutionHeight*1/this._zoomFactor}show(e){this._hidden=!e,this._renderer.updateVisibility(e)}isVisible(){return!this._hidden}setCameraZoom(e,t){this._zoomFactor=e,this._renderer.updatePosition()}getCameraZoom(e){return this._zoomFactor}getCameraRotation(e){return this._cameraRotation}setCameraRotation(e,t){this._cameraRotation=e,this._renderer.updatePosition()}convertCoords(e,t,a){e-=this._cachedGameResolutionWidth/2,t-=this._cachedGameResolutionHeight/2,e/=Math.abs(this._zoomFactor),t/=Math.abs(this._zoomFactor);const i=this._cameraRotation/180*Math.PI,o=e,r=Math.cos(i),s=Math.sin(i);return e=r*e-s*t,t=s*o+r*t,[e+this.getCameraX(a),t+this.getCameraY(a)]}convertInverseCoords(e,t,a){e-=this.getCameraX(a),t-=this.getCameraY(a);const i=this._cameraRotation/180*Math.PI,o=e,r=Math.cos(-i),s=Math.sin(-i);return e=r*e-s*t,t=s*o+r*t,e*=Math.abs(this._zoomFactor),t*=Math.abs(this._zoomFactor),[e+this._cachedGameResolutionWidth/2,t+this._cachedGameResolutionHeight/2]}getWidth(){return this._cachedGameResolutionWidth}getHeight(){return this._cachedGameResolutionHeight}getInitialEffectsData(){return this._initialEffectsData}addEffect(e){this._effectsManager.addEffect(e,this._rendererEffects,this._renderer.getRendererObject(),this)}removeEffect(e){this._effectsManager.removeEffect(this._rendererEffects,this._renderer.getRendererObject(),e)}setEffectDoubleParameter(e,t,a){this._effectsManager.setEffectDoubleParameter(this._rendererEffects,e,t,a)}setEffectStringParameter(e,t,a){this._effectsManager.setEffectStringParameter(this._rendererEffects,e,t,a)}setEffectBooleanParameter(e,t,a){this._effectsManager.setEffectBooleanParameter(this._rendererEffects,e,t,a)}enableEffect(e,t){this._effectsManager.enableEffect(this._rendererEffects,e,t)}isEffectEnabled(e){return this._effectsManager.isEffectEnabled(this._rendererEffects,e)}hasEffect(e){return this._effectsManager.hasEffect(this._rendererEffects,e)}setTimeScale(e){e>=0&&(this._timeScale=e)}getTimeScale(){return this._timeScale}getElapsedTime(e){return e=e||this._runtimeScene,e.getTimeManager().getElapsedTime()*this._timeScale}followBaseLayer(){const e=this._runtimeScene.getLayer("");this.setCameraX(e.getCameraX()),this.setCameraY(e.getCameraY()),this.setCameraRotation(e.getCameraRotation()),this.setCameraZoom(e.getCameraZoom())}getClearColor(){return this._clearColor}setClearColor(e,t,a){this._clearColor[0]=e/255,this._clearColor[1]=t/255,this._clearColor[2]=a/255,this._renderer.updateClearColor()}setFollowBaseLayerCamera(e){this._followBaseLayerCamera=e}isLightingLayer(){return this._isLightingLayer}}n.Layer=h})(gdjs||(gdjs={}));
//# sourceMappingURL=layer.js.map