UNPKG

starling-framework

Version:

A fast, productive library for 2D cross-platform development.

796 lines (781 loc) 34.3 kB
// Class: starling.core.Starling var $global = typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : this $global.Object.defineProperty(exports, "__esModule", {value: true}); var __map_reserved = {}; // Imports var $hxClasses = require("./../../hxClasses_stub").default; var $import = require("./../../import_stub").default; var $bind = require("./../../bind_stub").default; var $extend = require("./../../extend_stub").default; function starling_events_EventDispatcher() {return require("./../../starling/events/EventDispatcher");} function openfl__$Vector_Vector_$Impl_$() {return require("./../../openfl/_Vector/Vector_Impl_");} function openfl_Lib() {return $import(require("openfl/Lib"));} function Type() {return require("./../../Type");} function Std() {return require("./../../Std");} function starling_display_DisplayObject() {return require("./../../starling/display/DisplayObject");} function js__$Boot_HaxeError() {return require("./../../js/_Boot/HaxeError");} function openfl_errors_Error() {return $import(require("openfl/errors/Error"));} function starling_utils_Color() {return require("./../../starling/utils/Color");} function starling_utils_RectangleUtil() {return require("./../../starling/utils/RectangleUtil");} function starling_utils_Pool() {return require("./../../starling/utils/Pool");} function openfl_display_Shape() {return $import(require("openfl/display/Shape"));} function openfl_text_TextField() {return $import(require("openfl/text/TextField"));} function openfl_text_TextFormat() {return $import(require("openfl/text/TextFormat"));} function haxe_Log() {return require("./../../haxe/Log");} function openfl_system_Capabilities() {return $import(require("openfl/system/Capabilities"));} function haxe_Timer() {return require("./../../haxe/Timer");} function starling_events_KeyboardEvent() {return require("./../../starling/events/KeyboardEvent");} function js_Boot() {return require("./../../js/Boot");} function openfl_display_Stage() {return $import(require("openfl/display/Stage"));} function starling_events_ResizeEvent() {return require("./../../starling/events/ResizeEvent");} function openfl_events_MouseEvent() {return $import(require("openfl/events/MouseEvent"));} function openfl_events_TouchEvent() {return $import(require("openfl/events/TouchEvent"));} function starling_utils_MatrixUtil() {return require("./../../starling/utils/MatrixUtil");} function Reflect() {return require("./../../Reflect");} function starling_utils_SystemUtil() {return require("./../../starling/utils/SystemUtil");} function starling_core_StatsDisplay() {return require("./../../starling/core/StatsDisplay");} function openfl_errors_ArgumentError() {return $import(require("openfl/errors/ArgumentError"));} function openfl_display_DisplayObjectContainer() {return $import(require("openfl/display/DisplayObjectContainer"));} function openfl_ui_Multitouch() {return $import(require("openfl/ui/Multitouch"));} function openfl_geom_Rectangle() {return $import(require("openfl/geom/Rectangle"));} function starling_display_Stage() {return require("./../../starling/display/Stage");} function openfl_display_Sprite() {return $import(require("openfl/display/Sprite"));} function starling_events_TouchProcessor() {return require("./../../starling/events/TouchProcessor");} function starling_animation_Juggler() {return require("./../../starling/animation/Juggler");} function starling_rendering_Painter() {return require("./../../starling/rendering/Painter");} function openfl_ui_Mouse() {return $import(require("openfl/ui/Mouse"));} // Constructor var Starling = function(rootClass,stage,viewPort,stage3D,renderMode,profile,sharedContext) { if(profile == null) { profile = "auto"; } if(renderMode == null) { renderMode = "auto"; } (starling_events_EventDispatcher().default).call(this); if(stage == null) { throw new (js__$Boot_HaxeError().default)(new (openfl_errors_ArgumentError().default)("Stage must not be null")); } if(viewPort == null) { viewPort = new (openfl_geom_Rectangle().default)(0,0,stage.stageWidth,stage.stageHeight); } if(stage3D == null) { stage3D = stage.stage3Ds[0]; } (starling_utils_SystemUtil().default).initialize(); (openfl__$Vector_Vector_$Impl_$().default).push(Starling.sAll,this); this.makeCurrent(); this.__rootClass = rootClass; this.__viewPort = viewPort; this.__previousViewPort = new (openfl_geom_Rectangle().default)(); this.__stage = new (starling_display_Stage().default)((Std().default)["int"](viewPort.width),(Std().default)["int"](viewPort.height),stage.get_color()); this.__nativeOverlay = new (openfl_display_Sprite().default)(); this.__nativeStage = stage; this.__nativeStage.addChild(this.__nativeOverlay); this.__touchProcessor = new (starling_events_TouchProcessor().default)(this.__stage); this.__touchProcessor.set_discardSystemGestures(!(starling_utils_SystemUtil().default).get_isDesktop()); this.__juggler = new (starling_animation_Juggler().default)(); this.__antiAliasing = 0; this.__supportHighResolutions = false; this.__painter = new (starling_rendering_Painter().default)(stage3D,sharedContext); this.__frameTimestamp = (openfl_Lib().default).getTimer() / 1000.0; this.__frameID = 1; this.__supportsCursor = (openfl_ui_Mouse().default).supportsCursor || (openfl_system_Capabilities().default).get_os().indexOf("Windows") == 0; this.__statsDisplayAlign = { }; this.setMultitouchEnabled((openfl_ui_Multitouch().default).inputMode == "touchPoint",true); this.__nativeOverlayBlocksTouches = true; stage.scaleMode = "noScale"; stage.align = "topLeft"; stage.addEventListener("enterFrame",$bind(this,this.onEnterFrame),false,0,true); stage.addEventListener("keyDown",$bind(this,this.onKey),false,0,true); stage.addEventListener("keyUp",$bind(this,this.onKey),false,0,true); stage.addEventListener("resize",$bind(this,this.onResize),false,0,true); stage.addEventListener("mouseLeave",$bind(this,this.onMouseLeave),false,0,true); stage.addEventListener("activate",$bind(this,this.onActivate),false,0,true); stage3D.addEventListener("context3DCreate",$bind(this,this.onContextCreated),false,10,true); stage3D.addEventListener("error",$bind(this,this.onStage3DError),false,10,true); var runtimeVersion = 26; if(runtimeVersion < 19) { var runtime = (starling_utils_SystemUtil().default).get_isAIR() ? "Adobe AIR" : "Flash Player"; this.stopWithFatalError("Your " + runtime + " installation is outdated. " + "This software requires at least version 19."); } else if(this.__painter.get_shareContext()) { (haxe_Timer().default).delay($bind(this,this.initialize),1); } else { this.__painter.requestContext3D(renderMode,profile); } } // Meta Starling.__name__ = ["starling","core","Starling"]; Starling.__super__ = (starling_events_EventDispatcher().default); Starling.prototype = $extend((starling_events_EventDispatcher().default).prototype, { dispose: function() { this.stop(true); this.__nativeStage.removeEventListener("enterFrame",$bind(this,this.onEnterFrame),false); this.__nativeStage.removeEventListener("keyDown",$bind(this,this.onKey),false); this.__nativeStage.removeEventListener("keyUp",$bind(this,this.onKey),false); this.__nativeStage.removeEventListener("resize",$bind(this,this.onResize),false); this.__nativeStage.removeEventListener("mouseLeave",$bind(this,this.onMouseLeave),false); this.__nativeStage.removeChild(this.__nativeOverlay); this.get_stage3D().removeEventListener("context3DCreate",$bind(this,this.onContextCreated),false); this.get_stage3D().removeEventListener("context3DCreate",$bind(this,this.onContextRestored),false); this.get_stage3D().removeEventListener("error",$bind(this,this.onStage3DError),false); var _g = 0; var _g1 = this.getTouchEventTypes(this.__multitouchEnabled); while(_g < _g1.length) { var touchEventType = _g1[_g]; ++_g; this.__nativeStage.removeEventListener(touchEventType,$bind(this,this.onTouch),false); } if(this.__touchProcessor != null) { this.__touchProcessor.dispose(); } if(this.__painter != null) { this.__painter.dispose(); } if(this.__stage != null) { this.__stage.dispose(); } var this1 = Starling.sAll; var index = Array.prototype.indexOf.call(this1,this,0); if(index != -1) { (openfl__$Vector_Vector_$Impl_$().default).removeAt(Starling.sAll,index); } if(Starling.sCurrent == this) { Starling.sCurrent = null; } }, initialize: function() { this.makeCurrent(); this.updateViewPort(true); this.dispatchEventWith("context3DCreate",false,this.get_context()); this.initializeRoot(); this.__frameTimestamp = (openfl_Lib().default).getTimer() / 1000.0; }, initializeRoot: function() { if(this.__root == null && this.__rootClass != null) { this.__root = (Type().default).createInstance(this.__rootClass,[]); if(this.__root == null || !(Std().default)["is"](this.__root,(starling_display_DisplayObject().default))) { throw new (js__$Boot_HaxeError().default)(new (openfl_errors_Error().default)("Invalid root class: " + (Std().default).string(this.__rootClass))); } this.__stage.addChildAt(this.__root,0); this.dispatchEventWith("rootCreated",false,this.__root); } }, nextFrame: function() { var now = (openfl_Lib().default).getTimer() / 1000.0; var passedTime = now - this.__frameTimestamp; this.__frameTimestamp = now; if(passedTime > 1.0) { passedTime = 1.0; } if(passedTime < 0.0) { passedTime = 1.0 / this.__nativeStage.get_frameRate(); } this.advanceTime(passedTime); this.render(); }, advanceTime: function(passedTime) { if(!this.get_contextValid()) { return; } this.makeCurrent(); this.__touchProcessor.advanceTime(passedTime); this.__stage.advanceTime(passedTime); this.__juggler.advanceTime(passedTime); }, render: function() { if(!this.get_contextValid()) { return; } this.makeCurrent(); this.updateViewPort(); var doRedraw = this.__stage.get_requiresRedraw() || this.get_mustAlwaysRender(); if(doRedraw) { this.dispatchEventWith("render"); var shareContext = this.__painter.get_shareContext(); var scaleX = this.__viewPort.width / this.__stage.get_stageWidth(); var scaleY = this.__viewPort.height / this.__stage.get_stageHeight(); var stageColor = this.__stage.get_color(); this.__painter.nextFrame(); this.__painter.set_pixelSize(1.0 / this.get_contentScaleFactor()); this.__painter.get_state().setProjectionMatrix(this.__viewPort.x < 0 ? -this.__viewPort.x / scaleX : 0.0,this.__viewPort.y < 0 ? -this.__viewPort.y / scaleY : 0.0,this.__clippedViewPort.width / scaleX,this.__clippedViewPort.height / scaleY,this.__stage.get_stageWidth(),this.__stage.get_stageHeight(),this.__stage.get_cameraPosition()); if(!shareContext) { this.__painter.clear(stageColor,(starling_utils_Color().default).getAlpha(stageColor)); } this.__stage.render(this.__painter); this.__painter.finishFrame(); this.__painter.set_frameID(++this.__frameID); if(!shareContext) { this.__painter.present(); } } if(this.__statsDisplay != null) { this.__statsDisplay.set_drawCount(this.__painter.get_drawCount()); if(!doRedraw) { this.__statsDisplay.markFrameAsSkipped(); } } }, updateViewPort: function(forceUpdate) { if(forceUpdate == null) { forceUpdate = false; } if(forceUpdate || !(starling_utils_RectangleUtil().default).compare(this.__viewPort,this.__previousViewPort)) { this.__previousViewPort.setTo(this.__viewPort.x,this.__viewPort.y,this.__viewPort.width,this.__viewPort.height); this.updateClippedViewPort(); this.updateStatsDisplayPosition(); var contentScaleFactor = this.__supportHighResolutions ? this.__nativeStage.get_contentsScaleFactor() : 1.0; this.__painter.configureBackBuffer(this.__clippedViewPort,contentScaleFactor,this.__antiAliasing,true,this.__supportBrowserZoom); this.setRequiresRedraw(); } }, updateClippedViewPort: function() { var stageBounds = (starling_utils_Pool().default).getRectangle(0,0,this.__nativeStage.stageWidth,this.__nativeStage.stageHeight); this.__clippedViewPort = (starling_utils_RectangleUtil().default).intersect(this.__viewPort,stageBounds,this.__clippedViewPort); if(this.__clippedViewPort.width < 32) { this.__clippedViewPort.width = 32; } if(this.__clippedViewPort.height < 32) { this.__clippedViewPort.height = 32; } (starling_utils_Pool().default).putRectangle(stageBounds); }, updateNativeOverlay: function() { this.__nativeOverlay.set_x(this.__viewPort.x); this.__nativeOverlay.set_y(this.__viewPort.y); this.__nativeOverlay.set_scaleX(this.__viewPort.width / this.__stage.get_stageWidth()); this.__nativeOverlay.set_scaleY(this.__viewPort.height / this.__stage.get_stageHeight()); }, stopWithFatalError: function(message) { var background = new (openfl_display_Shape().default)(); background.get_graphics().beginFill(0,0.8); background.get_graphics().drawRect(0,0,this.__stage.get_stageWidth(),this.__stage.get_stageHeight()); background.get_graphics().endFill(); var textField = new (openfl_text_TextField().default)(); var textFormat = new (openfl_text_TextFormat().default)("_sans",14,16777215); textFormat.align = "center"; textField.set_defaultTextFormat(textFormat); textField.set_wordWrap(true); textField.set_width(this.__stage.get_stageWidth() * 0.75); textField.set_autoSize("center"); textField.set_text(message); textField.set_x((this.__stage.get_stageWidth() - textField.get_width()) / 2); textField.set_y((this.__stage.get_stageHeight() - textField.get_height()) / 2); textField.set_background(true); textField.set_backgroundColor(5570560); this.updateNativeOverlay(); this.get_nativeOverlay().addChild(background); this.get_nativeOverlay().addChild(textField); this.stop(true); (haxe_Log().default).trace("[Starling]",{ fileName : "Starling.hx", lineNumber : 616, className : "starling.core.Starling", methodName : "stopWithFatalError", customParams : [message]}); this.dispatchEventWith("fatalError",false,message); }, makeCurrent: function() { Starling.sCurrent = this; }, start: function() { this.__started = this.__rendering = true; this.__frameTimestamp = (openfl_Lib().default).getTimer() / 1000.0; }, stop: function(suspendRendering) { if(suspendRendering == null) { suspendRendering = false; } this.__started = false; this.__rendering = !suspendRendering; }, setRequiresRedraw: function() { this.__stage.setRequiresRedraw(); }, onStage3DError: function(event) { if(event.errorID == 3702) { var mode = (openfl_system_Capabilities().default).playerType == "Desktop" ? "renderMode" : "wmode"; this.stopWithFatalError("Context3D not available! Possible reasons: wrong " + mode + " or missing device support."); } else { this.stopWithFatalError("Stage3D error: " + event.text); } }, onContextCreated: function(event) { this.get_stage3D().removeEventListener("context3DCreate",$bind(this,this.onContextCreated)); this.get_stage3D().addEventListener("context3DCreate",$bind(this,this.onContextRestored),false,10,true); (haxe_Log().default).trace("[Starling] Context ready. Display Driver: " + this.get_context().driverInfo,{ fileName : "Starling.hx", lineNumber : 682, className : "starling.core.Starling", methodName : "onContextCreated"}); this.initialize(); }, onContextRestored: function(event) { (haxe_Log().default).trace("[Starling] Context restored.",{ fileName : "Starling.hx", lineNumber : 688, className : "starling.core.Starling", methodName : "onContextRestored"}); this.updateViewPort(true); this.dispatchEventWith("context3DCreate",false,this.get_context()); }, onEnterFrame: function(event) { if(!this.__painter.get_shareContext()) { if(this.__started) { this.nextFrame(); } else if(this.__rendering) { this.render(); } } this.updateNativeOverlay(); }, onActivate: function(event) { (haxe_Timer().default).delay($bind(this,this.setRequiresRedraw),100); }, onKey: function(event) { if(!this.__started) { return; } var keyEvent = new (starling_events_KeyboardEvent().default)(event.type,event.charCode,event.keyCode,event.keyLocation,event.ctrlKey,event.altKey,event.shiftKey); this.makeCurrent(); this.__stage.dispatchEvent(keyEvent); if(keyEvent.isDefaultPrevented()) { event.preventDefault(); } }, onResize: function(event) { var _gthis = this; var stageWidth = ((js_Boot().default).__cast(event.target , (openfl_display_Stage().default))).stageWidth; var stageHeight = ((js_Boot().default).__cast(event.target , (openfl_display_Stage().default))).stageHeight; var dispatchResizeEvent = null; dispatchResizeEvent = function() { _gthis.makeCurrent(); _gthis.removeEventListener("context3DCreate",dispatchResizeEvent); _gthis.__stage.dispatchEvent(new (starling_events_ResizeEvent().default)("resize",stageWidth,stageHeight)); }; var dispatchResizeEvent1 = dispatchResizeEvent; if(this.get_contextValid()) { dispatchResizeEvent1(); } else { this.addEventListener("context3DCreate",dispatchResizeEvent1); } }, onBrowserZoomChange: function(event) { }, onMouseLeave: function(event) { this.__touchProcessor.enqueueMouseLeftStage(); }, onTouch: function(event) { if(!this.__started) { return; } var globalX; var globalY; var touchID; var phase = null; var pressure = 1.0; var width = 1.0; var height = 1.0; if((Std().default)["is"](event,(openfl_events_MouseEvent().default))) { var mouseEvent = event; globalX = mouseEvent.stageX; globalY = mouseEvent.stageY; touchID = 0; if(event.type == "mouseDown") { this.__leftMouseDown = true; } else if(event.type == "mouseUp") { this.__leftMouseDown = false; } } else { var touchEvent = (js_Boot().default).__cast(event , (openfl_events_TouchEvent().default)); if(this.__supportsCursor && touchEvent.isPrimaryTouchPoint) { return; } else { globalX = touchEvent.stageX; globalY = touchEvent.stageY; touchID = touchEvent.touchPointID; pressure = touchEvent.pressure; width = touchEvent.sizeX; height = touchEvent.sizeY; } } var _g = event.type; switch(_g) { case "mouseDown": phase = "began"; break; case "mouseMove": if(this.__leftMouseDown) { phase = "moved"; } else { phase = "hover"; } break; case "mouseUp": phase = "ended"; break; case "touchBegin": phase = "began"; break; case "touchEnd": phase = "ended"; break; case "touchMove": phase = "moved"; break; } globalX = this.__stage.get_stageWidth() * (globalX - this.__viewPort.x) / this.__viewPort.width; globalY = this.__stage.get_stageHeight() * (globalY - this.__viewPort.y) / this.__viewPort.height; this.__touchProcessor.enqueue(touchID,phase,globalX,globalY,pressure,width,height); if(event.type == "mouseUp" && this.__supportsCursor) { this.__touchProcessor.enqueue(touchID,"hover",globalX,globalY); } }, hitTestNativeOverlay: function(localX,localY) { if(this.__nativeOverlay.get_numChildren() > 0) { var globalPos = (starling_utils_Pool().default).getPoint(); var matrix = (starling_utils_Pool().default).getMatrix(this.__nativeOverlay.get_scaleX(),0,0,this.__nativeOverlay.get_scaleY(),this.__nativeOverlay.get_x(),this.__nativeOverlay.get_y()); (starling_utils_MatrixUtil().default).transformCoords(matrix,localX,localY,globalPos); var result = this.__nativeOverlay.hitTestPoint(globalPos.x,globalPos.y,true); (starling_utils_Pool().default).putPoint(globalPos); (starling_utils_Pool().default).putMatrix(matrix); return result; } return false; }, setMultitouchEnabled: function(value,forceUpdate) { if(forceUpdate == null) { forceUpdate = false; } if(forceUpdate || value != this.__multitouchEnabled) { var oldEventTypes = this.getTouchEventTypes(this.__multitouchEnabled); var newEventTypes = this.getTouchEventTypes(value); var _g = 0; while(_g < oldEventTypes.length) { var oldEventType = oldEventTypes[_g]; ++_g; this.__nativeStage.removeEventListener(oldEventType,$bind(this,this.onTouch)); } var _g1 = 0; while(_g1 < newEventTypes.length) { var newEventType = newEventTypes[_g1]; ++_g1; this.__nativeStage.addEventListener(newEventType,$bind(this,this.onTouch),false,0,true); } this.__touchProcessor.cancelTouches(); this.__multitouchEnabled = value; } }, getTouchEventTypes: function(multitouchEnabled) { var types = []; if(multitouchEnabled) { types.push("touchBegin"); types.push("touchMove"); types.push("touchEnd"); } if(!multitouchEnabled || this.__supportsCursor) { types.push("mouseDown"); types.push("mouseMove"); types.push("mouseUp"); } return types; }, get_mustAlwaysRender: function() { if(!(Reflect().default).hasField(this.__nativeStage,"context3D") || (Reflect().default).field(this.__nativeStage,"context3D") == this.get_context()) { return true; } if(!this.__skipUnchangedFrames || this.__painter.get_shareContext()) { return true; } else if((starling_utils_SystemUtil().default).get_isDesktop() && this.get_profile() != "baselineConstrained") { return false; } else { var nativeStageEmpty = this.isNativeDisplayObjectEmpty(this.__nativeStage); var mustAlwaysRender = !nativeStageEmpty || !this.__nativeStageEmpty; this.__nativeStageEmpty = nativeStageEmpty; return mustAlwaysRender; } }, get_isStarted: function() { return this.__started; }, get_juggler: function() { return this.__juggler; }, get_painter: function() { return this.__painter; }, get_context: function() { return this.__painter.get_context(); }, get_simulateMultitouch: function() { return this.__touchProcessor.get_simulateMultitouch(); }, set_simulateMultitouch: function(value) { return this.__touchProcessor.set_simulateMultitouch(value); }, get_enableErrorChecking: function() { return this.__painter.get_enableErrorChecking(); }, set_enableErrorChecking: function(value) { return this.__painter.set_enableErrorChecking(value); }, get_antiAliasing: function() { return this.__antiAliasing; }, set_antiAliasing: function(value) { if(this.__antiAliasing != value) { this.__antiAliasing = value; if(this.get_contextValid()) { this.updateViewPort(true); } } return value; }, get_viewPort: function() { return this.__viewPort; }, set_viewPort: function(value) { this.__viewPort.copyFrom(value); return value; }, get_contentScaleFactor: function() { return this.__viewPort.width * this.__painter.get_backBufferScaleFactor() / this.__stage.get_stageWidth(); }, get_nativeOverlay: function() { return this.__nativeOverlay; }, get_nativeOverlayBlocksTouches: function() { return this.__touchProcessor.get_occlusionTest() != null; }, set_nativeOverlayBlocksTouches: function(value) { if(value != this.__nativeOverlayBlocksTouches) { this.__touchProcessor.set_occlusionTest(value ? $bind(this,this.hitTestNativeOverlay) : null); } return value; }, get_showStats: function() { return this.__showStats; }, set_showStats: function(value) { this.__showStats = value; if(value) { var h = (Reflect().default).hasField(this.__statsDisplayAlign,"horizontal") ? this.__statsDisplayAlign.horizontal : null; var v = (Reflect().default).hasField(this.__statsDisplayAlign,"vertical") ? this.__statsDisplayAlign.vertical : null; this.showStatsAt(h != null ? h : "left",v != null ? v : "top"); } else if(this.__statsDisplay != null) { this.__statsDisplay.removeFromParent(); } return value; }, showStatsAt: function(horizontalAlign,verticalAlign,scale) { if(scale == null) { scale = 1; } if(verticalAlign == null) { verticalAlign = "top"; } if(horizontalAlign == null) { horizontalAlign = "left"; } var _gthis = this; var onRootCreated = null; onRootCreated = function() { if(_gthis.__showStats) { _gthis.showStatsAt(horizontalAlign,verticalAlign,scale); } _gthis.removeEventListener("rootCreated",onRootCreated); }; var onRootCreated1 = onRootCreated; this.__showStats = true; this.__statsDisplayAlign.horizontal = horizontalAlign; this.__statsDisplayAlign.vertical = verticalAlign; if(this.get_context() == null) { this.addEventListener("rootCreated",onRootCreated1); } else { if(this.__statsDisplay == null) { this.__statsDisplay = new (starling_core_StatsDisplay().default)(); this.__statsDisplay.set_touchable(false); } this.__stage.addChild(this.__statsDisplay); this.__statsDisplay.set_scaleX(this.__statsDisplay.set_scaleY(scale)); this.updateClippedViewPort(); this.updateStatsDisplayPosition(); } }, updateStatsDisplayPosition: function() { if(!this.__showStats || this.__statsDisplay == null) { return; } var horizontalAlign = this.__statsDisplayAlign.horizontal; var verticalAlign = this.__statsDisplayAlign.vertical; var scaleX = this.__viewPort.width / this.__stage.get_stageWidth(); var scaleY = this.__viewPort.height / this.__stage.get_stageHeight(); var clipping = (starling_utils_Pool().default).getRectangle(this.__viewPort.x < 0 ? -this.__viewPort.x / scaleX : 0.0,this.__viewPort.y < 0 ? -this.__viewPort.y / scaleY : 0.0,this.__clippedViewPort.width / scaleX,this.__clippedViewPort.height / scaleY); if(horizontalAlign == "left") { this.__statsDisplay.set_x(clipping.x); } else if(horizontalAlign == "right") { this.__statsDisplay.set_x(clipping.get_right() - this.__statsDisplay.get_width()); } else if(horizontalAlign == "center") { this.__statsDisplay.set_x((clipping.get_right() - this.__statsDisplay.get_width()) / 2); } else { throw new (js__$Boot_HaxeError().default)(new (openfl_errors_ArgumentError().default)("Invalid horizontal alignment: " + horizontalAlign)); } if(verticalAlign == "top") { this.__statsDisplay.set_y(clipping.y); } else if(verticalAlign == "bottom") { this.__statsDisplay.set_y(clipping.get_bottom() - this.__statsDisplay.get_height()); } else if(verticalAlign == "center") { this.__statsDisplay.set_y((clipping.get_bottom() - this.__statsDisplay.get_height()) / 2); } else { throw new (js__$Boot_HaxeError().default)(new (openfl_errors_ArgumentError().default)("Invalid vertical alignment: " + verticalAlign)); } (starling_utils_Pool().default).putRectangle(clipping); }, get_stage: function() { return this.__stage; }, get_stage3D: function() { return this.__painter.get_stage3D(); }, get_nativeStage: function() { return this.__nativeStage; }, get_root: function() { return this.__root; }, get_rootClass: function() { return this.__rootClass; }, set_rootClass: function(value) { if(this.__rootClass != null && this.__root != null) { throw new (js__$Boot_HaxeError().default)(new (openfl_errors_Error().default)("Root class may not change after root has been instantiated")); } else if(this.__rootClass == null) { this.__rootClass = value; if(this.get_context() != null) { this.initializeRoot(); } } return value; }, get_shareContext: function() { return this.__painter.get_shareContext(); }, set_shareContext: function(value) { if(!value) { this.__previousViewPort.setEmpty(); } return this.__painter.set_shareContext(value); }, get_profile: function() { return this.__painter.get_profile(); }, get_supportHighResolutions: function() { return this.__supportHighResolutions; }, set_supportHighResolutions: function(value) { if(this.__supportHighResolutions != value) { this.__supportHighResolutions = value; if(this.get_contextValid()) { this.updateViewPort(true); } } return value; }, get_supportBrowserZoom: function() { return this.__supportBrowserZoom; }, set_supportBrowserZoom: function(value) { if(this.__supportBrowserZoom != value) { this.__supportBrowserZoom = value; } return value; }, get_skipUnchangedFrames: function() { return this.__skipUnchangedFrames; }, set_skipUnchangedFrames: function(value) { this.__skipUnchangedFrames = value; this.__nativeStageEmpty = false; return value; }, get_touchProcessor: function() { return this.__touchProcessor; }, set_touchProcessor: function(value) { if(value == null) { throw new (js__$Boot_HaxeError().default)(new (openfl_errors_ArgumentError().default)("TouchProcessor must not be null")); } else if(value != this.__touchProcessor) { this.__touchProcessor.dispose(); this.__touchProcessor = value; } return value; }, get_discardSystemGestures: function() { return this.__touchProcessor.get_discardSystemGestures(); }, set_discardSystemGestures: function(value) { this.__touchProcessor.set_discardSystemGestures(value); return value; }, get_frameID: function() { return this.__frameID; }, get_contextValid: function() { return this.__painter.get_contextValid(); }, isNativeDisplayObjectEmpty: function(object) { if(object == null) { return true; } else if((Std().default)["is"](object,(openfl_display_DisplayObjectContainer().default))) { var container = object; var numChildren = container.get_numChildren(); var _g1 = 0; var _g = numChildren; while(_g1 < _g) { var i = _g1++; if(!this.isNativeDisplayObjectEmpty(container.getChildAt(i))) { return false; } } return true; } else { return !object.get_visible(); } } }); Starling.prototype.__class__ = Starling.prototype.constructor = $hxClasses["starling.core.Starling"] = Starling; // Init { Object.defineProperties(Starling.prototype,{ "touchEventTypes" : { get : function () { return this.get_touchEventTypes (); }}, "mustAlwaysRender" : { get : function () { return this.get_mustAlwaysRender (); }}, "isStarted" : { get : function () { return this.get_isStarted (); }}, "juggler" : { get : function () { return this.get_juggler (); }}, "context" : { get : function () { return this.get_context (); }, set : function (v) { return this.set_context (v); }}, "simulateMultitouch" : { get : function () { return this.get_simulateMultitouch (); }, set : function (v) { return this.set_simulateMultitouch (v); }}, "enableErrorChecking" : { get : function () { return this.get_enableErrorChecking (); }, set : function (v) { return this.set_enableErrorChecking (v); }}, "antiAliasing" : { get : function () { return this.get_antiAliasing (); }, set : function (v) { return this.set_antiAliasing (v); }}, "viewPort" : { get : function () { return this.get_viewPort (); }, set : function (v) { return this.set_viewPort (v); }}, "contentScaleFactor" : { get : function () { return this.get_contentScaleFactor (); }}, "nativeOverlay" : { get : function () { return this.get_nativeOverlay (); }}, "nativeOverlayBlocksTouches" : { get : function () { return this.get_nativeOverlayBlocksTouches (); }, set : function (v) { return this.set_nativeOverlayBlocksTouches (v); }}, "showStats" : { get : function () { return this.get_showStats (); }, set : function (v) { return this.set_showStats (v); }}, "stage" : { get : function () { return this.get_stage (); }}, "stage3D" : { get : function () { return this.get_stage3D (); }}, "nativeStage" : { get : function () { return this.get_nativeStage (); }}, "root" : { get : function () { return this.get_root (); }}, "rootClass" : { get : function () { return this.get_rootClass (); }, set : function (v) { return this.set_rootClass (v); }}, "shareContext" : { get : function () { return this.get_shareContext (); }, set : function (v) { return this.set_shareContext (v); }}, "profile" : { get : function () { return this.get_profile (); }}, "supportHighResolutions" : { get : function () { return this.get_supportHighResolutions (); }, set : function (v) { return this.set_supportHighResolutions (v); }}, "skipUnchangedFrames" : { get : function () { return this.get_skipUnchangedFrames (); }, set : function (v) { return this.set_skipUnchangedFrames (v); }}, "touchProcessor" : { get : function () { return this.get_touchProcessor (); }, set : function (v) { return this.set_touchProcessor (v); }}, "discardSystemGestures" : { get : function () { return this.get_discardSystemGestures (); }, set : function (v) { return this.set_discardSystemGestures (v); }}, "frameID" : { get : function () { return this.get_frameID (); }}, "contextValid" : { get : function () { return this.get_contextValid (); }}}); Object.defineProperties(Starling,{ "current" : { get : function () { return Starling.get_current (); }}, "all" : { get : function () { return Starling.get_all (); }}, "contentScaleFactor" : { get : function () { return Starling.get_contentScaleFactor (); }}, "multitouchEnabled" : { get : function () { return Starling.get_multitouchEnabled (); }, set : function (v) { return Starling.set_multitouchEnabled (v); }}}); }; // Statics Starling.get_current = function() { return Starling.sCurrent; } Starling.get_all = function() { return Starling.sAll; } Starling.get_multitouchEnabled = function() { var enabled = (openfl_ui_Multitouch().default).inputMode == "touchPoint"; var outOfSync = false; var _g = 0; var _g1 = Starling.sAll; while(_g < _g1.length) { var star = _g1[_g]; ++_g; if(star.__multitouchEnabled != enabled) { outOfSync = true; } } if(outOfSync) { (haxe_Log().default).trace("[Starling] Warning: multitouch settings are out of sync. Always set " + "'Starling.multitouchEnabled' instead of 'Multitouch.inputMode'.",{ fileName : "Starling.hx", lineNumber : 1296, className : "starling.core.Starling", methodName : "get_multitouchEnabled"}); } return enabled; } Starling.set_multitouchEnabled = function(value) { var wasEnabled = (openfl_ui_Multitouch().default).inputMode == "touchPoint"; (openfl_ui_Multitouch().default).inputMode = value ? "touchPoint" : "none"; var isEnabled = (openfl_ui_Multitouch().default).inputMode == "touchPoint"; if(wasEnabled != isEnabled) { var _g = 0; var _g1 = Starling.sAll; while(_g < _g1.length) { var star = _g1[_g]; ++_g; star.setMultitouchEnabled(isEnabled); } } return value; } Starling.VERSION = null Starling.sAll = (openfl__$Vector_Vector_$Impl_$().default)._new() // Export exports.default = Starling;