├── .gitignore ├── .gitmodules ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── flexCompiler.xml ├── misc.xml ├── modules.xml ├── scopes │ └── scope_settings.xml └── vcs.xml ├── README.md ├── buildscript ├── build.properties └── build.xml ├── deliverable ├── EmbeddedComponents.swf └── EmbeddedTheme.swf ├── libs └── DragonBonesAS-4_1.swc ├── particle └── src │ ├── de │ └── flintfabrik │ │ └── starling │ │ ├── display │ │ ├── FFParticleSystem.as │ │ └── FFParticleSystem │ │ │ ├── Frame.as │ │ │ ├── Particle.as │ │ │ └── SystemOptions.as │ │ └── utils │ │ └── ColorArgb.as │ └── starlingbuilder │ └── extensions │ └── particle │ └── FFParticleSprite.as ├── sgn-starling-builder-extensions.iml ├── tests └── src │ ├── Main-app.xml │ ├── Main.as │ ├── TestAll.as │ ├── TestApp.as │ ├── boostslot_bg_green.png │ ├── dbanimations │ ├── dragon.dat │ ├── dragon.png │ └── dragon.xml │ ├── generic_gift.png │ ├── starling │ └── extensions │ │ ├── GaugeFactory.as │ │ └── PixelMaskDisplayObjectFactory.as │ └── starlingbuilder │ └── extensions │ ├── animation │ ├── DBAssetMediator.as │ └── DBSpriteFactory.as │ ├── particle │ ├── FFParticleSpriteFactory.as │ ├── default.pex │ └── default.png │ └── uicomponents │ ├── AbstractDisplayObjectFactory.as │ ├── ContainerButtonFactory.as │ ├── GradientQuadFactory.as │ ├── IDisplayObjectFactory.as │ └── ImageFactory.as ├── theme ├── assets │ ├── fonts │ │ ├── SourceSansPro-Regular.ttf │ │ └── SourceSansPro-Semibold.ttf │ └── images │ │ ├── metalworks_mobile.png │ │ └── metalworks_mobile.xml └── src │ ├── EmbeddedTheme.as │ └── feathers │ └── themes │ ├── BaseTestGameMobileTheme.as │ └── TestGameMobileTheme.as └── ui-components └── src ├── EmbeddedComponents.as ├── custom_component_template.json ├── starling └── extensions │ ├── Gauge.as │ └── pixelmask │ └── PixelMaskDisplayObject.as └── starlingbuilder └── extensions ├── animation └── DBSprite.as └── uicomponents ├── ContainerButton.as └── GradientQuad.as /.gitignore: -------------------------------------------------------------------------------- 1 | out/ 2 | .idea/workspace.xml -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "starling-builder-editor"] 2 | path = starling-builder-editor 3 | url = https://github.com/mindjolt/starling-builder-editor 4 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | sgn-starling-builder-extensions -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/flexCompiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/scopes/scope_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Starling Builder extensions 2 | 3 | ####Overview 4 | 5 | Starling Builder extension is the place you can extend Starling Builder without modifying the [editor](https://github.com/mindjolt/starling-builder-editor). 6 | 7 | Build the swfs here and simplily drop them into the YOUR_WORKSPACE/libs. 8 | 9 | For the time being, you can build your custom UI components into EmbeddedComponents.swf and build your feathers theme into EmebeddedTheme.swf. 10 | 11 | ####Check out extensions repository: 12 | ``` 13 | git clone https://github.com/mindjolt/starling-builder-extensions --recursive 14 | ``` 15 | 16 | ####Documentation 17 | 18 | For more information, please visit our wiki page at http://wiki.starling-framework.org/builder/extensions 19 | 20 | -------------------------------------------------------------------------------- /buildscript/build.properties: -------------------------------------------------------------------------------- 1 | airsdk.root = /Users/hyh/sdks/AIRSDK_19 2 | airsdk.bin = ${airsdk.root}/bin 3 | airsdk.lib = ${airsdk.root}/lib 4 | airsdk.config = ${airsdk.root}/frameworks/flex-config.xml 5 | airsdk.framework = ${airsdk.root}/frameworks 6 | 7 | 8 | compc = ${airsdk.lib}/compc-cli.jar 9 | mxmlc = ${airsdk.lib}/mxmlc-cli.jar 10 | 11 | adl = ${airsdk.bin}/adl 12 | 13 | swf-version = 30 -------------------------------------------------------------------------------- /buildscript/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /deliverable/EmbeddedComponents.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mindjolt/starling-builder-extensions/b3a3fcf1f1c5cbed9d354ba5dab8feed218856fb/deliverable/EmbeddedComponents.swf -------------------------------------------------------------------------------- /deliverable/EmbeddedTheme.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mindjolt/starling-builder-extensions/b3a3fcf1f1c5cbed9d354ba5dab8feed218856fb/deliverable/EmbeddedTheme.swf -------------------------------------------------------------------------------- /libs/DragonBonesAS-4_1.swc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mindjolt/starling-builder-extensions/b3a3fcf1f1c5cbed9d354ba5dab8feed218856fb/libs/DragonBonesAS-4_1.swc -------------------------------------------------------------------------------- /particle/src/de/flintfabrik/starling/display/FFParticleSystem/Frame.as: -------------------------------------------------------------------------------- 1 | // ================================================================================================= 2 | // 3 | // Starling Framework - Particle System Extension 4 | // Copyright 2011 Gamua OG. All Rights Reserved. 5 | // 6 | // This program is free software. You can redistribute and/or modify it 7 | // in accordance with the terms of the accompanying license agreement. 8 | // 9 | // ================================================================================================= 10 | 11 | package de.flintfabrik.starling.display.FFParticleSystem 12 | { 13 | 14 | public class Frame 15 | { 16 | 17 | public var particleHalfWidth:Number = 1.0; 18 | public var particleHalfHeight:Number = 1.0; 19 | public var textureX:Number = 0.0; 20 | public var textureY:Number = 0.0; 21 | public var textureWidth:Number = 1.0; 22 | public var textureHeight:Number = 1.0; 23 | public var rotated:Boolean = false; 24 | 25 | public function Frame(nativeTextureWidth:Number = 64, nativeTextureHeight:Number = 64, x:Number = 0.0, y:Number = 0.0, width:Number = 64.0, height:Number = 64.0, rotated:Boolean = false) 26 | { 27 | textureX = x / nativeTextureWidth; 28 | textureY = y / nativeTextureHeight; 29 | textureWidth = (x + width) / nativeTextureWidth; 30 | textureHeight = (y + height) / nativeTextureHeight; 31 | particleHalfWidth = (width) >> 1; 32 | particleHalfHeight = (height) >> 1; 33 | this.rotated = rotated; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /particle/src/de/flintfabrik/starling/display/FFParticleSystem/Particle.as: -------------------------------------------------------------------------------- 1 | // ================================================================================================= 2 | // 3 | // Starling Framework - Particle System Extension 4 | // Copyright 2011 Gamua OG. All Rights Reserved. 5 | // 6 | // This program is free software. You can redistribute and/or modify it 7 | // in accordance with the terms of the accompanying license agreement. 8 | // 9 | // ================================================================================================= 10 | 11 | package de.flintfabrik.starling.display.FFParticleSystem 12 | { 13 | public class Particle 14 | { 15 | 16 | public var x:Number = 0.0; 17 | public var y:Number = 0.0; 18 | public var scale:Number = 1.0; 19 | public var rotation:Number = 0.0; 20 | public var alpha:Number = 1.0; 21 | public var currentTime:Number = 0; 22 | public var totalTime:Number = 1.0; 23 | 24 | public var colorRed:Number = 1.0; 25 | public var colorGreen:Number = 1.0; 26 | public var colorBlue:Number = 1.0; 27 | public var colorAlpha:Number = 1.0; 28 | 29 | public var colorDeltaRed:Number = 0.0; 30 | public var colorDeltaGreen:Number = 0.0; 31 | public var colorDeltaBlue:Number = 0.0; 32 | public var colorDeltaAlpha:Number = 0.0; 33 | 34 | public var startX:Number = 0.0; 35 | public var startY:Number = 0.0; 36 | public var velocityX:Number = 0.0; 37 | public var velocityY:Number = 0.0; 38 | public var radialAcceleration:Number = 0.0; 39 | public var tangentialAcceleration:Number = 0.0; 40 | public var emitRadius:Number = 1.0; 41 | public var emitRadiusDelta:Number = 0.0; 42 | public var emitRotation:Number = 0.0; 43 | public var emitRotationDelta:Number = 0.0; 44 | public var rotationDelta:Number = 0.0; 45 | public var scaleDelta:Number = 0.0; 46 | public var frameIdx:int = 0; 47 | public var frame:Number = 0; 48 | public var frameDelta:Number = 0; 49 | 50 | public var fadeInFactor:Number = 0; 51 | public var fadeOutFactor:Number = 0; 52 | public var spawnFactor:Number = 0; 53 | 54 | public var active:Boolean = false; 55 | 56 | public var customValues:Object; 57 | 58 | public function Particle() { } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /particle/src/de/flintfabrik/starling/display/FFParticleSystem/SystemOptions.as: -------------------------------------------------------------------------------- 1 | // ================================================================================================= 2 | // 3 | // Starling Framework - Particle System Extension 4 | // Copyright 2011 Gamua OG. All Rights Reserved. 5 | // 6 | // This program is free software. You can redistribute and/or modify it 7 | // in accordance with the terms of the accompanying license agreement. 8 | // 9 | // ================================================================================================= 10 | 11 | package de.flintfabrik.starling.display.FFParticleSystem 12 | { 13 | import de.flintfabrik.starling.display.FFParticleSystem.Frame; 14 | import de.flintfabrik.starling.utils.ColorArgb; 15 | import flash.display3D.Context3DBlendFactor; 16 | import flash.geom.Rectangle; 17 | import starling.filters.FragmentFilter; 18 | import starling.textures.*; 19 | 20 | /** 21 | * The SystemOption object is ment to interprete given PEX and TextureAtlas xml files 22 | * cache and modify the values for instanciation of a particle system, since XML parsing 23 | * is extremly expensive. 24 | */ 25 | public class SystemOptions 26 | { 27 | private var mFirstFrameName:String = ""; 28 | private var mLastFrameName:String = ""; 29 | 30 | /** 31 | * The number of frames to animate, alternatively to setting the index with lastFrame. 32 | */ 33 | public var animationLength:Number = 1; 34 | /** 35 | * A Boolean setting whether the texture should be animated or not. 36 | */ 37 | public var isAnimated:Boolean = false; 38 | /** 39 | * A int to set the first frames index in the texture atlas. 40 | */ 41 | public var firstFrame:uint = 0; 42 | /** 43 | * A int to set the last frames index in the texture atlas. 44 | * -1 will be set the last frame to the highest value possible. 45 | */ 46 | public var lastFrame:int = -1; 47 | /** 48 | * A uint (1 or higher) setting the number of animation loops if the texture is animated. 49 | */ 50 | public var loops:uint = 1; 51 | /** 52 | * A Boolean setting whether the initial frame should be chosen randomly. 53 | */ 54 | public var randomStartFrames:Boolean = false; 55 | 56 | /** 57 | * A Boolean setting whether particles shall be tinted. 58 | */ 59 | public var tinted:Boolean = true; 60 | 61 | /** 62 | * A Boolean overriding the premultiplied alpha value of the system. 63 | */ 64 | public var premultipliedAlpha:Boolean = true; 65 | 66 | /** 67 | * A Number between 0 and 1 setting the timespan to fade in particles. 68 | */ 69 | public var spawnTime:Number = 0; 70 | 71 | /** 72 | * A Number between 0 and 1 setting the timespan to fade in particles. 73 | */ 74 | public var fadeInTime:Number = 0; 75 | 76 | /** 77 | * A Number between 0 and 1 setting the timespan to fade out particles. 78 | */ 79 | public var fadeOutTime:Number = 0; 80 | 81 | /** 82 | * A uint setting the emitter type to EMITTER_TYPE_GRAVITY:int = 0; or 83 | * EMITTER_TYPE_RADIAL:int = 1; 84 | */ 85 | public var emitterType:Number = 0; 86 | /** 87 | * A uint setting the maximum number of particles used by this FFParticleSystem 88 | */ 89 | public var maxParticles:uint = 10; 90 | /** 91 | * The horizontal emitter position 92 | */ 93 | public var sourceX:Number = 0; 94 | /** 95 | * The vertical emitter position 96 | */ 97 | public var sourceY:Number = 0; 98 | 99 | public var sourceVarianceX:Number = 0; 100 | public var sourceVarianceY:Number = 0; 101 | public var lifespan:Number = 1; 102 | public var lifespanVariance:Number = 0; 103 | public var angle:Number = 0; 104 | public var angleVariance:Number = 0; 105 | /** 106 | * Aligns the particles to their emit angle at birth. 107 | * 108 | * @see angle 109 | */ 110 | public var emitAngleAlignedRotation:Boolean = false; 111 | public var startParticleSize:Number = 20; 112 | public var startParticleSizeVariance:Number = 0; 113 | public var finishParticleSize:Number = 20; 114 | public var finishParticleSizeVariance:Number = 0; 115 | public var rotationStart:Number = 0; 116 | public var rotationStartVariance:Number = 0; 117 | public var rotationEnd:Number = 0; 118 | public var rotationEndVariance:Number = 0; 119 | /** 120 | * The emission time span. Pass to -1 set the emission time to infinite. 121 | */ 122 | public var duration:Number = 2; 123 | 124 | public var gravityX:Number = 0; 125 | public var gravityY:Number = 0; 126 | /** 127 | * The speed of a particle in pixel per seconds. 128 | */ 129 | public var speed:Number = 50; 130 | public var speedVariance:Number = 0; 131 | 132 | public var radialAcceleration:Number = 0; 133 | public var radialAccelerationVariance:Number = 0; 134 | public var tangentialAcceleration:Number = 0; 135 | public var tangentialAccelerationVariance:Number = 0; 136 | 137 | public var maxRadius:Number = 100; 138 | public var maxRadiusVariance:Number = 0; 139 | public var minRadius:Number = 0; 140 | public var minRadiusVariance:Number = 0; 141 | public var rotatePerSecond:Number = 0; 142 | public var rotatePerSecondVariance:Number = 0; 143 | 144 | public var startColor:ColorArgb = new ColorArgb(1, 1, 1, 1); 145 | public var startColorVariance:ColorArgb = new ColorArgb(0, 0, 0, 0); 146 | public var finishColor:ColorArgb = new ColorArgb(1, 1, 1, 1); 147 | public var finishColorVariance:ColorArgb = new ColorArgb(0, 0, 0, 0); 148 | 149 | public var filter:FragmentFilter; 150 | public var customFunction:Function; 151 | public var sortFunction:Function; 152 | public var forceSortFlag:Boolean = false; 153 | 154 | /** 155 | * Sets the blend function for rendering the source. 156 | * @see #blendFactorDestination 157 | * @see flash.display3D.Context3DBlendFactor 158 | */ 159 | public var blendFuncSource:String = Context3DBlendFactor.ONE; 160 | /** 161 | * Sets the blend function for rendering the destination. 162 | * @see #blendFactorSource 163 | * @see flash.display3D.Context3DBlendFactor 164 | */ 165 | public var blendFuncDestination:String = Context3DBlendFactor.ONE_MINUS_SOURCE_ALPHA; 166 | 167 | /** 168 | * A Boolean that determines whether the FFParticleSystem should calculate it's exact bounds or return stage dimensions 169 | */ 170 | public var excactBounds:Boolean = false; 171 | 172 | /** 173 | * The look up table containing information about all frames within the animation 174 | */ 175 | public var mFrameLUT:Vector.; 176 | 177 | public function get frameLUT():Vector. 178 | { 179 | if (!mFrameLUT) 180 | updateFrameLUT(); 181 | return mFrameLUT; 182 | } 183 | /** 184 | * The texture used by the particle system. 185 | */ 186 | public var texture:Texture; 187 | /** 188 | * The atlas xml file for the used texture 189 | */ 190 | public var atlasXML:XML; 191 | 192 | /** 193 | * Creates a new SystemOptions instance. 194 | * 195 | * @see fromXML() 196 | * @see clone() 197 | */ 198 | public function SystemOptions(texture:Texture, atlasXML:XML = null, config:XML = null) 199 | { 200 | if (!texture) 201 | throw new Error("texture must not be null"); 202 | 203 | this.texture = texture; 204 | this.atlasXML = atlasXML; 205 | 206 | if (config) 207 | SystemOptions.fromXML(config, texture, atlasXML, this); 208 | } 209 | 210 | /** 211 | * Modifies given properties of a SystemOptions instance. 212 | * @param object 213 | * @return A new SystemOptions instance with given parameters 214 | */ 215 | public function appendFromObject(object:Object):SystemOptions 216 | { 217 | 218 | for (var p:String in object) 219 | { 220 | try 221 | { 222 | this[p] = object[p]; 223 | } 224 | catch (err:*) 225 | { 226 | trace(err.toString()); 227 | } 228 | } 229 | 230 | updateFrameLUT(); 231 | 232 | return this; 233 | } 234 | 235 | /** 236 | * Returns a copy of the SystemOptions instance. 237 | * @param systemOptions A SystemOptions instance 238 | * @return A new SystemOptions instance with given parameters 239 | */ 240 | public function clone(target:SystemOptions = null):SystemOptions 241 | { 242 | if (!target) 243 | target = new SystemOptions(this.texture, this.atlasXML); 244 | 245 | target.texture = texture; 246 | target.atlasXML = atlasXML; 247 | 248 | target.sourceX = this.sourceX; 249 | target.sourceY = this.sourceY; 250 | target.sourceVarianceX = this.sourceVarianceX; 251 | target.sourceVarianceY = this.sourceVarianceY; 252 | target.gravityX = this.gravityX; 253 | target.gravityY = this.gravityY; 254 | target.emitterType = this.emitterType; 255 | target.maxParticles = this.maxParticles; 256 | target.lifespan = this.lifespan; 257 | target.lifespanVariance = this.lifespanVariance; 258 | target.startParticleSize = this.startParticleSize; 259 | target.startParticleSizeVariance = this.startParticleSizeVariance; 260 | target.finishParticleSize = this.finishParticleSize; 261 | target.finishParticleSizeVariance = this.finishParticleSizeVariance; 262 | target.angle = this.angle; 263 | target.angleVariance = this.angleVariance; 264 | target.rotationStart = this.rotationStart; 265 | target.rotationStartVariance = this.rotationStartVariance; 266 | target.rotationEnd = this.rotationEnd; 267 | target.rotationEndVariance = this.rotationEndVariance; 268 | target.emitAngleAlignedRotation = this.emitAngleAlignedRotation; 269 | target.speed = this.speed; 270 | target.speedVariance = this.speedVariance; 271 | target.radialAcceleration = this.radialAcceleration; 272 | target.radialAccelerationVariance = this.radialAccelerationVariance; 273 | target.tangentialAcceleration = this.tangentialAcceleration; 274 | target.tangentialAccelerationVariance = this.tangentialAccelerationVariance; 275 | target.maxRadius = this.maxRadius; 276 | target.maxRadiusVariance = this.maxRadiusVariance; 277 | target.minRadius = this.minRadius; 278 | target.minRadiusVariance = this.minRadiusVariance; 279 | target.rotatePerSecond = this.rotatePerSecond; 280 | target.rotatePerSecondVariance = this.rotatePerSecondVariance; 281 | target.startColor = this.startColor; 282 | target.startColorVariance = this.startColorVariance; 283 | target.finishColor = this.finishColor; 284 | target.finishColorVariance = this.finishColorVariance; 285 | target.blendFuncSource = this.blendFuncSource; 286 | target.blendFuncDestination = this.blendFuncDestination; 287 | target.duration = this.duration; 288 | 289 | target.isAnimated = this.isAnimated; 290 | target.firstFrameName = this.firstFrameName; 291 | target.firstFrame = this.firstFrame; 292 | target.lastFrameName = this.lastFrameName; 293 | target.lastFrame = this.lastFrame; 294 | target.lastFrame = this.lastFrame; 295 | target.loops = this.loops; 296 | target.randomStartFrames = this.randomStartFrames; 297 | target.tinted = this.tinted; 298 | target.spawnTime = this.spawnTime; 299 | target.fadeInTime = this.fadeInTime; 300 | target.fadeOutTime = this.fadeOutTime; 301 | target.excactBounds = this.excactBounds; 302 | 303 | target.filter = this.filter; 304 | target.customFunction = this.customFunction; 305 | target.sortFunction = this.sortFunction; 306 | target.forceSortFlag = this.forceSortFlag; 307 | 308 | target.mFrameLUT = this.mFrameLUT; 309 | 310 | return target; 311 | } 312 | 313 | /** 314 | * Exports current settings to XML file. 315 | * @param target 316 | * @return 317 | */ 318 | public function exportConfig(atlasXML:XML = null):XML 319 | { 320 | var tempAtlas:XML = atlasXML ? atlasXML : this.atlasXML; 321 | var target:XML = XML(''); 322 | 323 | target.angle.@value = isNaN(angle) ? 0 : angle.toFixed(2); 324 | target.angleVariance.@value = isNaN(angleVariance) ? 0 : angleVariance.toFixed(2); 325 | target.duration.@value = isNaN(duration) ? 0 : duration.toFixed(2); 326 | target.emitterType.@value = isNaN(emitterType) ? 0 : emitterType.toFixed(2); 327 | target.emitAngleAlignedRotation.@value = int(emitAngleAlignedRotation); 328 | target.excactBounds.@value = int(excactBounds); 329 | target.finishParticleSize.@value = isNaN(finishParticleSize) ? 10 : finishParticleSize.toFixed(2); 330 | target.finishParticleSizeVariance.@value = isNaN(finishParticleSizeVariance) ? 0 : finishParticleSizeVariance.toFixed(2); 331 | target.gravity.@x = isNaN(gravityX) ? 0 : gravityX.toFixed(2); 332 | target.gravity.@y = isNaN(gravityY) ? 0 : gravityY.toFixed(2); 333 | if (isAnimated || randomStartFrames || firstFrame != 0) 334 | { 335 | if (!tempAtlas) 336 | trace("Warning: atlasXML is not defined - frame names will be set as integers."); 337 | target.animation.isAnimated.@value = int(isAnimated); 338 | target.animation.firstFrame.@value = getFrameNameFromAtlas(firstFrame, tempAtlas); 339 | target.animation.lastFrame.@value = getFrameNameFromAtlas(lastFrame, tempAtlas); 340 | target.animation.loops.@value = loops; 341 | target.animation.randomStartFrames.@value = int(randomStartFrames); 342 | } 343 | target.maxParticles.@value = isNaN(maxParticles) ? 0 : maxParticles.toFixed(2); 344 | target.maxRadius.@value = isNaN(maxRadius) ? 0 : maxRadius.toFixed(2); 345 | target.maxRadiusVariance.@value = isNaN(maxRadiusVariance) ? 0 : maxRadiusVariance.toFixed(2); 346 | target.minRadius.@value = isNaN(minRadius) ? 0 : minRadius.toFixed(2); 347 | target.minRadiusVariance.@value = isNaN(minRadiusVariance) ? 0 : minRadiusVariance.toFixed(2); 348 | target.particleLifeSpan.@value = isNaN(lifespan) ? 0 : lifespan.toFixed(2); 349 | target.particleLifespanVariance.@value = isNaN(lifespanVariance) ? 0 : lifespanVariance.toFixed(2); 350 | target.radialAcceleration.@value = isNaN(radialAcceleration) ? 0 : radialAcceleration.toFixed(2); 351 | target.radialAccelVariance.@value = isNaN(radialAccelerationVariance) ? 0 : radialAccelerationVariance.toFixed(2); 352 | target.rotatePerSecond.@value = isNaN(rotatePerSecond) ? 0 : rotatePerSecond.toFixed(2); 353 | target.rotatePerSecondVariance.@value = isNaN(rotatePerSecondVariance) ? 0 : rotatePerSecondVariance.toFixed(2); 354 | target.rotationEnd.@value = isNaN(rotationEnd) ? 0 : rotationEnd.toFixed(2); 355 | target.rotationEndVariance.@value = isNaN(rotationEndVariance) ? 0 : rotationEndVariance.toFixed(2); 356 | target.rotationStart.@value = isNaN(rotationStart) ? 0 : rotationStart.toFixed(2); 357 | target.rotationStartVariance.@value = isNaN(rotationStartVariance) ? 0 : rotationStartVariance.toFixed(2); 358 | target.sourcePosition.@x = isNaN(sourceX) ? 0 : sourceX.toFixed(2); 359 | target.sourcePosition.@y = isNaN(sourceY) ? 0 : sourceY.toFixed(2); 360 | target.sourcePositionVariance.@x = isNaN(sourceVarianceX) ? 0 : sourceVarianceX.toFixed(2); 361 | target.sourcePositionVariance.@y = isNaN(sourceVarianceY) ? 0 : sourceVarianceY.toFixed(2); 362 | target.speed.@value = isNaN(speed) ? 0 : speed.toFixed(2); 363 | target.speedVariance.@value = isNaN(speedVariance) ? 0 : speedVariance.toFixed(2); 364 | target.startParticleSize.@value = isNaN(startParticleSize) ? 10 : startParticleSize.toFixed(2); 365 | target.startParticleSizeVariance.@value = isNaN(startParticleSizeVariance) ? 0 : startParticleSizeVariance.toFixed(2); 366 | target.tangentialAcceleration.@value = isNaN(tangentialAcceleration) ? 0 : tangentialAcceleration.toFixed(2); 367 | target.tangentialAccelVariance.@value = isNaN(tangentialAccelerationVariance) ? 0 : tangentialAccelerationVariance.toFixed(2); 368 | target.tinted.@value = int(tinted); 369 | target.premultipliedAlpha.@value = Boolean(premultipliedAlpha); 370 | 371 | target.startColor.@red = isNaN(startColor.red) ? 1 : startColor.red; 372 | target.startColor.@green = isNaN(startColor.green) ? 1 : startColor.green; 373 | target.startColor.@blue = isNaN(startColor.blue) ? 1 : startColor.blue; 374 | target.startColor.@alpha = isNaN(startColor.alpha) ? 1 : startColor.alpha; 375 | 376 | target.startColorVariance.@red = isNaN(startColorVariance.red) ? 0 : startColorVariance.red; 377 | target.startColorVariance.@green = isNaN(startColorVariance.green) ? 0 : startColorVariance.green; 378 | target.startColorVariance.@blue = isNaN(startColorVariance.blue) ? 0 : startColorVariance.blue; 379 | target.startColorVariance.@alpha = isNaN(startColorVariance.alpha) ? 0 : startColorVariance.alpha; 380 | 381 | target.finishColor.@red = isNaN(finishColor.red) ? 1 : finishColor.red; 382 | target.finishColor.@green = isNaN(finishColor.green) ? 1 : finishColor.green; 383 | target.finishColor.@blue = isNaN(finishColor.blue) ? 1 : finishColor.blue; 384 | target.finishColor.@alpha = isNaN(finishColor.alpha) ? 1 : finishColor.alpha; 385 | 386 | target.finishColorVariance.@red = isNaN(finishColorVariance.red) ? 0 : finishColorVariance.red; 387 | target.finishColorVariance.@green = isNaN(finishColorVariance.green) ? 0 : finishColorVariance.green; 388 | target.finishColorVariance.@blue = isNaN(finishColorVariance.blue) ? 0 : finishColorVariance.blue; 389 | target.finishColorVariance.@alpha = isNaN(finishColorVariance.alpha) ? 0 : finishColorVariance.alpha; 390 | 391 | target.blendFuncSource.@value = blendFuncSource.replace(/([A-Z])/g, '_$1').toUpperCase(); 392 | target.blendFuncDestination.@value = blendFuncDestination.replace(/([A-Z])/g, '_$1').toUpperCase(); 393 | 394 | return target; 395 | } 396 | 397 | private function getFrameNameFromAtlas(idx:int, atlasXML:XML = null):String 398 | { 399 | if (atlasXML == null) 400 | return idx.toString(); 401 | var name:String = atlasXML.SubTexture[idx].@name; 402 | if (atlasXML.SubTexture.(@name == name).length() == 1) 403 | { 404 | return name; 405 | } 406 | else 407 | { 408 | return idx.toString(); 409 | } 410 | } 411 | 412 | /** 413 | * Interpretation of the .pex config XML 414 | * @param config The .pex config XML file 415 | * @param texture The texture used by the FFParticleSystem 416 | * @param atlasXML TextureAtlas XML file necessary for animated Particles 417 | * @param target An optional to write data 418 | * @return 419 | */ 420 | public static function fromXML(config:XML, texture:Texture, atlasXML:XML = null, target:SystemOptions = null):SystemOptions 421 | { 422 | if (!target) 423 | target = new SystemOptions(texture, atlasXML); 424 | 425 | target.texture = texture; 426 | target.atlasXML = atlasXML; 427 | 428 | target.sourceX = parseFloat(config.sourcePosition.attribute("x")); 429 | target.sourceY = parseFloat(config.sourcePosition.attribute("y")); 430 | target.sourceVarianceX = parseFloat(config.sourcePositionVariance.attribute("x")); 431 | target.sourceVarianceY = parseFloat(config.sourcePositionVariance.attribute("y")); 432 | target.gravityX = parseFloat(config.gravity.attribute("x")); 433 | target.gravityY = parseFloat(config.gravity.attribute("y")); 434 | target.emitterType = getIntValue(config.emitterType); 435 | target.maxParticles = getIntValue(config.maxParticles); 436 | target.lifespan = Math.max(0.01, getFloatValue(config.particleLifeSpan)); 437 | target.lifespanVariance = getFloatValue(config.particleLifespanVariance); 438 | target.startParticleSize = getFloatValue(config.startParticleSize); 439 | target.startParticleSizeVariance = getFloatValue(config.startParticleSizeVariance); 440 | target.finishParticleSize = getFloatValue(config.finishParticleSize); 441 | target.finishParticleSizeVariance = getFloatValue(config.finishParticleSizeVariance); 442 | target.angle = getFloatValue(config.angle); 443 | target.angleVariance = getFloatValue(config.angleVariance); 444 | target.rotationStart = getFloatValue(config.rotationStart); 445 | target.rotationStartVariance = getFloatValue(config.rotationStartVariance); 446 | target.rotationEnd = getFloatValue(config.rotationEnd); 447 | target.rotationEndVariance = getFloatValue(config.rotationEndVariance); 448 | target.emitAngleAlignedRotation = getBooleanValue(config.emitAngleAlignedRotation); 449 | target.speed = getFloatValue(config.speed); 450 | target.speedVariance = getFloatValue(config.speedVariance); 451 | target.radialAcceleration = getFloatValue(config.radialAcceleration); 452 | target.radialAccelerationVariance = getFloatValue(config.radialAccelVariance); 453 | target.tangentialAcceleration = getFloatValue(config.tangentialAcceleration); 454 | target.tangentialAccelerationVariance = getFloatValue(config.tangentialAccelVariance); 455 | target.maxRadius = getFloatValue(config.maxRadius); 456 | target.maxRadiusVariance = getFloatValue(config.maxRadiusVariance); 457 | target.minRadius = getFloatValue(config.minRadius); 458 | target.minRadiusVariance = getFloatValue(config.minRadiusVariance); 459 | target.rotatePerSecond = getFloatValue(config.rotatePerSecond); 460 | target.rotatePerSecondVariance = getFloatValue(config.rotatePerSecondVariance); 461 | getColor(config.startColor, target.startColor); 462 | getColor(config.startColorVariance, target.startColorVariance); 463 | getColor(config.finishColor, target.finishColor); 464 | getColor(config.finishColorVariance, target.finishColorVariance); 465 | target.blendFuncSource = getBlendFunc(config.blendFuncSource); 466 | target.blendFuncDestination = getBlendFunc(config.blendFuncDestination); 467 | target.duration = getFloatValue(config.duration); 468 | 469 | if (isNaN(target.finishParticleSizeVariance)) 470 | target.finishParticleSizeVariance = getFloatValue(config.FinishParticleSizeVariance); 471 | if (isNaN(target.lifespan)) 472 | target.lifespan = Math.max(0.01, getFloatValue(config.particleLifespan)); 473 | if (isNaN(target.lifespanVariance)) 474 | target.lifespanVariance = getFloatValue(config.particleLifeSpanVariance); 475 | 476 | // new introduced properties // 477 | if (config.animation.length()) 478 | { 479 | //var atlasName:String = config.animation.atlas.@name // not used ... just some info to identify the actual textureAtlas.xml file name, and debugging 480 | 481 | var node:XMLList = config.animation.isAnimated; 482 | 483 | if (node.length()) 484 | target.isAnimated = getBooleanValue(node) && atlasXML; 485 | 486 | node = config.animation.firstFrame; 487 | if (node.length()) 488 | { 489 | target.firstFrameName = node.attribute("value"); 490 | if (target.firstFrameName == "") 491 | target.firstFrame = getIntValue(node); 492 | } 493 | 494 | node = config.animation.lastFrame; 495 | if (node.length()) 496 | { 497 | target.lastFrameName = node.attribute("value"); 498 | if (target.lastFrameName == "") 499 | target.lastFrame = getIntValue(node); 500 | } 501 | 502 | node = config.animation.numberOfAnimatedFrames; 503 | if (node.length()) 504 | target.lastFrame = (node.length() ? int(target.firstFrame) + (target.animationLength = getIntValue(node)) : target.lastFrame).toString(); 505 | 506 | node = config.animation.loops; 507 | if (node.length()) 508 | target.loops = getFloatValue(node); 509 | 510 | node = config.animation.randomStartFrames; 511 | if (node.length()) 512 | target.randomStartFrames = getBooleanValue(node); 513 | } 514 | node = config.tinted; 515 | if (node.length()) 516 | target.tinted = getBooleanValue(node); 517 | node = config.premultipliedAlpha; 518 | if (node.length()) 519 | target.premultipliedAlpha = getBooleanValue(node); 520 | node = config.spawnTime; 521 | if (node.length()) 522 | target.spawnTime = getFloatValue(node); 523 | node = config.fadeInTime; 524 | if (node.length()) 525 | target.fadeInTime = getFloatValue(node); 526 | node = config.fadeOutTime; 527 | if (node.length()) 528 | target.fadeOutTime = getFloatValue(node); 529 | node = config.excactBounds; 530 | if (node.length()) 531 | target.excactBounds = getBooleanValue(node); 532 | // end of new properties // 533 | 534 | target.updateFrameLUT(); 535 | 536 | return target; 537 | } 538 | 539 | private static function getFrameIdx(value:String, atlasXML:XML):int 540 | { 541 | if (atlasXML && isNaN(Number(value))) 542 | { 543 | var idx:int = atlasXML.SubTexture.(@name == value).childIndex(); 544 | if (idx == -1) 545 | trace('frame "' + value + '" not found in atlas!'); 546 | return idx; 547 | } 548 | else 549 | { 550 | return int(value); 551 | } 552 | } 553 | 554 | private static function getBooleanValue(element:XMLList):Boolean 555 | { 556 | if (element[0]) 557 | { 558 | var valueStr:String = (element.attribute("value")).toLowerCase(); 559 | var valueInt:int = parseInt(element.attribute("value")); 560 | var result:Boolean = valueStr == "true" || valueInt > 0; 561 | return result; 562 | } 563 | return false; 564 | } 565 | 566 | private static function getIntValue(element:XMLList):int 567 | { 568 | var result:int = parseInt(element.attribute("value")); 569 | return isNaN(result) ? 0 : result; 570 | } 571 | 572 | private static function getFloatValue(element:XMLList):Number 573 | { 574 | var result:Number = parseFloat(element.attribute("value")); 575 | return isNaN(result) ? 0 : result; 576 | } 577 | 578 | private static function getColor(element:XMLList, color:ColorArgb):ColorArgb 579 | { 580 | if (!color) 581 | color = new ColorArgb(); 582 | 583 | var val:Number; 584 | val = parseFloat(element.attribute("red")); 585 | if (!isNaN(val)) 586 | color.red = val; 587 | val = parseFloat(element.attribute("green")); 588 | if (!isNaN(val)) 589 | color.green = val; 590 | val = parseFloat(element.attribute("blue")); 591 | if (!isNaN(val)) 592 | color.blue = val; 593 | val = parseFloat(element.attribute("alpha")); 594 | if (!isNaN(val)) 595 | color.alpha = val; 596 | return color; 597 | } 598 | 599 | private static function getBlendFunc(element:XMLList):String 600 | { 601 | var str:String = element.attribute("value"); 602 | if (isNaN(Number(str)) && Context3DBlendFactor[str] !== undefined) 603 | { 604 | return Context3DBlendFactor[str]; 605 | } 606 | var value:int = getIntValue(element); 607 | switch (value) 608 | { 609 | case 0: 610 | return Context3DBlendFactor.ZERO; 611 | break; 612 | case 1: 613 | return Context3DBlendFactor.ONE; 614 | break; 615 | case 0x300: 616 | return Context3DBlendFactor.SOURCE_COLOR; 617 | break; 618 | case 0x301: 619 | return Context3DBlendFactor.ONE_MINUS_SOURCE_COLOR; 620 | break; 621 | case 0x302: 622 | return Context3DBlendFactor.SOURCE_ALPHA; 623 | break; 624 | case 0x303: 625 | return Context3DBlendFactor.ONE_MINUS_SOURCE_ALPHA; 626 | break; 627 | case 0x304: 628 | return Context3DBlendFactor.DESTINATION_ALPHA; 629 | break; 630 | case 0x305: 631 | return Context3DBlendFactor.ONE_MINUS_DESTINATION_ALPHA; 632 | break; 633 | case 0x306: 634 | return Context3DBlendFactor.DESTINATION_COLOR; 635 | break; 636 | case 0x307: 637 | return Context3DBlendFactor.ONE_MINUS_DESTINATION_COLOR; 638 | break; 639 | default: 640 | throw new ArgumentError("unsupported blending function: " + value); 641 | } 642 | } 643 | 644 | /** 645 | * Parses the texture atlas xml and stores subtexture positions/dimensions in a look up table. 646 | * If the texture is a SubTexture, it will also look for this frame in the texture atlas, to set this SubTexture as first frame. 647 | * 648 | *

Note: each frame will be stored once per loop in frameLUT since the modulo operator is expensive.

649 | */ 650 | public function updateFrameLUT():void 651 | { 652 | mFrameLUT = new []; 653 | 654 | if (atlasXML) 655 | { 656 | var w:int = texture.root.nativeWidth; 657 | var h:int = texture.root.nativeHeight; 658 | 659 | firstFrame = Math.min(firstFrame, atlasXML.SubTexture.length() - 1) 660 | lastFrame = lastFrame == -1 ? atlasXML.SubTexture.length() : lastFrame; 661 | 662 | if (texture && texture is SubTexture) 663 | { 664 | // look for subtexture with same properties as the subtexture, on success we'll use it as firstFrame 665 | var st:SubTexture = SubTexture(texture); 666 | var rect:Rectangle = st.clipping; 667 | 668 | rect.x *= st.root.nativeWidth; 669 | rect.y *= st.root.nativeHeight; 670 | rect.width *= st.root.nativeWidth; 671 | rect.height *= st.root.nativeHeight; 672 | 673 | var matches:XMLList = atlasXML.SubTexture.(@x == rect.x).(@y == rect.y).(@width == rect.width).(@height == rect.height); 674 | 675 | if (matches.length() >= 1 && firstFrame == 0) 676 | { 677 | var idx:int = matches[0].childIndex(); 678 | if (idx >= 0) 679 | { 680 | firstFrame = idx; 681 | } 682 | } 683 | } 684 | 685 | lastFrame = Math.max(firstFrame, Math.min(lastFrame, atlasXML.SubTexture.length() - 1)); 686 | 687 | var animationLoopLength:int = lastFrame - firstFrame + 1; 688 | isAnimated = isAnimated && animationLoopLength > 1; 689 | loops = isAnimated ? loops + (randomStartFrames ? 1 : 0) : 1; 690 | animationLoopLength = isAnimated || randomStartFrames ? animationLoopLength : 1; 691 | for (var l:int = 0; l < loops; ++l) 692 | { 693 | for (var i:int = 0; i < animationLoopLength; ++i) 694 | { 695 | var subTexture:XML = atlasXML.SubTexture[i + firstFrame]; 696 | var x:Number = parseFloat(subTexture.attribute("x")); 697 | var y:Number = parseFloat(subTexture.attribute("y")); 698 | var width:Number = parseFloat(subTexture.attribute("width")); 699 | var height:Number = parseFloat(subTexture.attribute("height")); 700 | var rotated:Boolean = Boolean(subTexture.attribute("rotated") == 1 || subTexture.attribute("rotated") == true); 701 | mFrameLUT[i + l * animationLoopLength] = new Frame(w, h, x, y, width, height, rotated); 702 | } 703 | } 704 | 705 | var mNumberOfFrames:int = mFrameLUT.length - 1 - (randomStartFrames && isAnimated ? animationLoopLength : 0); 706 | var mFrameLUTLength:int = mFrameLUT.length - 1; 707 | isAnimated = isAnimated && mFrameLUT.length > 1; 708 | randomStartFrames = randomStartFrames && mFrameLUT.length > 1; 709 | } 710 | else 711 | { 712 | if (texture is SubTexture) 713 | { 714 | //subtexture 715 | st = SubTexture(texture); 716 | var wf:Number = st.parent.width * st.scale; 717 | var hf:Number = st.parent.height * st.scale; 718 | mFrameLUT[0] = new Frame(st.root.nativeWidth, st.root.nativeHeight, st.clipping.x * wf, st.clipping.y * hf, st.clipping.width * wf, st.clipping.height * hf, st.rotated); 719 | } 720 | else 721 | { 722 | //rootTexture 723 | mFrameLUT[0] = new Frame(texture.width, texture.height, 0, 0, texture.width, texture.height, false); 724 | } 725 | } 726 | 727 | mFrameLUT.fixed = true; 728 | } 729 | 730 | public function get firstFrameName():String 731 | { 732 | return mFirstFrameName; 733 | } 734 | 735 | public function set firstFrameName(value:String):void 736 | { 737 | var idx:int = getFrameIdx(value, atlasXML); 738 | if (idx != -1) 739 | { 740 | firstFrame = idx; 741 | mFirstFrameName = value; 742 | } 743 | else 744 | { 745 | mFirstFrameName = ""; 746 | } 747 | } 748 | 749 | public function get lastFrameName():String 750 | { 751 | return mLastFrameName; 752 | } 753 | 754 | public function set lastFrameName(value:String):void 755 | { 756 | var idx:int = getFrameIdx(value, atlasXML); 757 | if (idx != -1) 758 | { 759 | lastFrame = getFrameIdx(value, atlasXML); 760 | mLastFrameName = value; 761 | } 762 | else 763 | { 764 | mLastFrameName = ""; 765 | } 766 | } 767 | 768 | } 769 | } 770 | -------------------------------------------------------------------------------- /particle/src/de/flintfabrik/starling/utils/ColorArgb.as: -------------------------------------------------------------------------------- 1 | // ================================================================================================= 2 | // 3 | // Starling Framework - Particle System Extension 4 | // Copyright 2011 Gamua OG. All Rights Reserved. 5 | // 6 | // This program is free software. You can redistribute and/or modify it 7 | // in accordance with the terms of the accompanying license agreement. 8 | // 9 | // ================================================================================================= 10 | 11 | package de.flintfabrik.starling.utils 12 | { 13 | public class ColorArgb 14 | { 15 | public var red:Number; 16 | public var green:Number; 17 | public var blue:Number; 18 | public var alpha:Number; 19 | 20 | public static function fromRgb(color:uint):ColorArgb 21 | { 22 | var rgb:ColorArgb = new ColorArgb(); 23 | rgb.fromRgb(color); 24 | return rgb; 25 | } 26 | 27 | public static function fromArgb(color:uint):ColorArgb 28 | { 29 | var argb:ColorArgb = new ColorArgb(); 30 | argb.fromArgb(color); 31 | return argb; 32 | } 33 | 34 | public function ColorArgb(red:Number=0, green:Number=0, blue:Number=0, alpha:Number=0) 35 | { 36 | this.red = red; 37 | this.green = green; 38 | this.blue = blue; 39 | this.alpha = alpha; 40 | } 41 | 42 | public function toRgb():uint 43 | { 44 | var r:Number = red; if (r < 0.0) r = 0.0; else if (r > 1.0) r = 1.0; 45 | var g:Number = green; if (g < 0.0) g = 0.0; else if (g > 1.0) g = 1.0; 46 | var b:Number = blue; if (b < 0.0) b = 0.0; else if (b > 1.0) b = 1.0; 47 | 48 | return int(r * 255) << 16 | int(g * 255) << 8 | int(b * 255); 49 | } 50 | 51 | public function toArgb():uint 52 | { 53 | var a:Number = alpha; if (a < 0.0) a = 0.0; else if (a > 1.0) a = 1.0; 54 | var r:Number = red; if (r < 0.0) r = 0.0; else if (r > 1.0) r = 1.0; 55 | var g:Number = green; if (g < 0.0) g = 0.0; else if (g > 1.0) g = 1.0; 56 | var b:Number = blue; if (b < 0.0) b = 0.0; else if (b > 1.0) b = 1.0; 57 | 58 | return int(a * 255) << 24 | int(r * 255) << 16 | int(g * 255) << 8 | int(b * 255); 59 | } 60 | 61 | public function fromRgb(color:uint):void 62 | { 63 | red = (color >> 16 & 0xFF) / 255.0; 64 | green = (color >> 8 & 0xFF) / 255.0; 65 | blue = (color & 0xFF) / 255.0; 66 | } 67 | 68 | public function fromArgb(color:uint):void 69 | { 70 | red = (color >> 16 & 0xFF) / 255.0; 71 | green = (color >> 8 & 0xFF) / 255.0; 72 | blue = (color & 0xFF) / 255.0; 73 | alpha = (color >> 24 & 0xFF) / 255.0; 74 | } 75 | 76 | public function copyFrom(argb:ColorArgb):void 77 | { 78 | red = argb.red; 79 | green = argb.green; 80 | blue = argb.blue; 81 | alpha = argb.alpha; 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /particle/src/starlingbuilder/extensions/particle/FFParticleSprite.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by hyh on 4/30/16. 3 | */ 4 | package starlingbuilder.extensions.particle 5 | { 6 | import de.flintfabrik.starling.display.FFParticleSystem; 7 | import de.flintfabrik.starling.display.FFParticleSystem.SystemOptions; 8 | 9 | import flash.geom.Matrix; 10 | import flash.geom.Point; 11 | 12 | import flash.geom.Rectangle; 13 | 14 | import starling.display.DisplayObject; 15 | 16 | import starling.display.Sprite; 17 | import starling.textures.Texture; 18 | import starling.utils.MatrixUtil; 19 | 20 | public class FFParticleSprite extends Sprite 21 | { 22 | // helper objects 23 | private static var sHelperMatrix:Matrix = new Matrix(); 24 | private static var sHelperPoint:Point = new Point(); 25 | 26 | private static var _optionCache:Object = {}; 27 | 28 | private var _particleId:String; 29 | private var _texture:Texture; 30 | private var _config:XML; 31 | 32 | private var _cacheParticle:Boolean = true; 33 | 34 | private var _sprite:FFParticleSystem; 35 | 36 | public function FFParticleSprite() 37 | { 38 | super(); 39 | } 40 | 41 | public function get texture():Texture 42 | { 43 | return _texture; 44 | } 45 | 46 | public function set texture(value:Texture):void 47 | { 48 | _texture = value; 49 | createParticle(); 50 | } 51 | 52 | public function get config():XML 53 | { 54 | return _config; 55 | } 56 | 57 | public function set config(value:XML):void 58 | { 59 | _config = value; 60 | createParticle(); 61 | } 62 | 63 | public function get particleId():String 64 | { 65 | return _particleId; 66 | } 67 | 68 | public function set particleId(value:String):void 69 | { 70 | _particleId = value; 71 | createParticle(); 72 | } 73 | 74 | private function createParticle():void 75 | { 76 | if (_sprite) 77 | { 78 | _sprite.removeFromParent(true); 79 | _sprite = null; 80 | } 81 | 82 | if (_texture == null || _config == null || _particleId == null || _particleId == "") 83 | return; 84 | 85 | _sprite = new FFParticleSystem(getSystemOptions()); 86 | _sprite.touchable = false; 87 | _sprite.start(); 88 | addChild(_sprite); 89 | } 90 | 91 | private function getSystemOptions():SystemOptions 92 | { 93 | if (!(_particleId in _optionCache) || !_cacheParticle) 94 | { 95 | _optionCache[_particleId] = SystemOptions.fromXML(_config, _texture); 96 | } 97 | 98 | return _optionCache[_particleId]; 99 | } 100 | 101 | public static function addSystemOptions(particleId:String, config:XML, texture:Texture):void 102 | { 103 | _optionCache[particleId] = SystemOptions.fromXML(config, texture); 104 | } 105 | 106 | public static function removeSystemOptions(particleId:String):void 107 | { 108 | delete _optionCache[particleId]; 109 | } 110 | 111 | public function get cacheParticle():Boolean 112 | { 113 | return _cacheParticle; 114 | } 115 | 116 | public function set cacheParticle(value:Boolean):void 117 | { 118 | _cacheParticle = value; 119 | } 120 | 121 | override public function getBounds(targetSpace:DisplayObject, out:Rectangle=null):Rectangle 122 | { 123 | if (out == null) out = new Rectangle(); 124 | 125 | getTransformationMatrix(targetSpace, sHelperMatrix); 126 | MatrixUtil.transformCoords(sHelperMatrix, 0.0, 0.0, sHelperPoint); 127 | out.setTo(sHelperPoint.x, sHelperPoint.y, 0, 0); 128 | 129 | return out; 130 | } 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /sgn-starling-builder-extensions.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | -------------------------------------------------------------------------------- /tests/src/Main-app.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 12 | 13 | 15 | Main 16 | 17 | 18 | Main 19 | 20 | 21 | Main 22 | 23 | 26 | 0.0.0 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 47 | 48 | 49 | 50 | 51 | Main.swf 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | true 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | true 97 | 98 | 99 | true 100 | 101 | 102 | direct 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 153 | 154 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | UIDeviceFamily 189 | 190 | 191 | 1 192 | 193 | 2 194 | 195 | 196 | 197 | 198 | 199 | ]]> 200 | 201 | 202 | 203 | 212 | 213 | 214 | high 215 | 216 | 217 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 248 | 249 | ]]> 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | -------------------------------------------------------------------------------- /tests/src/Main.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Starling Builder 3 | * Copyright 2015 SGN Inc. All Rights Reserved. 4 | * 5 | * This program is free software. You can redistribute and/or modify it in 6 | * accordance with the terms of the accompanying license agreement. 7 | */ 8 | package { 9 | import flash.display.Sprite; 10 | import flash.events.Event; 11 | import starling.core.Starling; 12 | import starling.utils.HAlign; 13 | import starling.utils.VAlign; 14 | 15 | [SWF(frameRate=60, width=800, height=800, backgroundColor="#000")] 16 | public class Main extends Sprite 17 | { 18 | private var _starling : Starling; 19 | 20 | public function Main() 21 | { 22 | addEventListener(Event.ENTER_FRAME, onEnterFrame); 23 | } 24 | 25 | private function _start(e:Event):void 26 | { 27 | _starling.start(); 28 | } 29 | 30 | private function onEnterFrame(event:Event):void 31 | { 32 | removeEventListener(Event.ENTER_FRAME, onEnterFrame); 33 | init(); 34 | } 35 | 36 | private function init():void 37 | { 38 | Starling.handleLostContext = true; 39 | 40 | _starling = new Starling(TestApp, stage); 41 | 42 | _starling.simulateMultitouch = false; 43 | _starling.enableErrorChecking = false; 44 | _starling.showStatsAt(HAlign.RIGHT, VAlign.TOP); 45 | _starling.supportHighResolutions = true; 46 | 47 | _starling.stage3D.addEventListener(Event.CONTEXT3D_CREATE, _start); 48 | } 49 | } 50 | } 51 | 52 | -------------------------------------------------------------------------------- /tests/src/TestAll.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by hyh on 3/7/16. 3 | */ 4 | package 5 | { 6 | [SWF(frameRate=60, width=800, height=800, backgroundColor="#000")] 7 | public class TestAll extends Main 8 | { 9 | public function TestAll() 10 | { 11 | super(); 12 | TestApp.TEST_ALL = true; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/src/TestApp.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Starling Builder 3 | * Copyright 2015 SGN Inc. All Rights Reserved. 4 | * 5 | * This program is free software. You can redistribute and/or modify it in 6 | * accordance with the terms of the accompanying license agreement. 7 | */ 8 | package { 9 | 10 | import feathers.controls.LayoutGroup; 11 | import feathers.core.IFeathersControl; 12 | import feathers.core.PopUpManager; 13 | import feathers.layout.AnchorLayout; 14 | import feathers.themes.TestGameMobileTheme; 15 | 16 | import flash.filesystem.File; 17 | 18 | import flash.utils.Dictionary; 19 | 20 | import starling.core.Starling; 21 | import starling.display.DisplayObject; 22 | import starling.display.Sprite; 23 | import starling.display.Stage; 24 | import starling.events.Event; 25 | import starling.events.ResizeEvent; 26 | import starling.extensions.GaugeFactory; 27 | import starling.extensions.PixelMaskDisplayObjectFactory; 28 | import starling.textures.Texture; 29 | import starling.utils.AssetManager; 30 | 31 | import starlingbuilder.editor.controller.ComponentRenderSupport; 32 | 33 | import starlingbuilder.editor.data.TemplateData; 34 | import starlingbuilder.editor.helper.AssetMediator; 35 | import starlingbuilder.editor.themes.BaseMetalWorksDesktopTheme2; 36 | import starlingbuilder.editor.themes.IUIEditorThemeMediator; 37 | import starlingbuilder.editor.themes.MetalWorksDesktopTheme2; 38 | import starlingbuilder.editor.ui.AbstractPropertyPopup; 39 | import starlingbuilder.editor.ui.AssetTab; 40 | import starlingbuilder.editor.ui.DefaultEditPropertyPopup; 41 | import starlingbuilder.editor.ui.DisplayObjectPropertyPopup; 42 | import starlingbuilder.editor.ui.ScaleTextureConstructorPopup1; 43 | import starlingbuilder.editor.ui.TextureConstructorPopup; 44 | import starlingbuilder.editor.ui.TexturePropertyPopup; 45 | import starlingbuilder.engine.IAssetMediator; 46 | import starlingbuilder.engine.IUIBuilder; 47 | import starlingbuilder.engine.UIBuilder; 48 | import starlingbuilder.engine.util.ParamUtil; 49 | import starlingbuilder.extensions.animation.DBAssetMediator; 50 | import starlingbuilder.extensions.animation.DBSpriteFactory; 51 | import starlingbuilder.extensions.particle.FFParticleSpriteFactory; 52 | import starlingbuilder.extensions.uicomponents.ContainerButtonFactory; 53 | import starlingbuilder.extensions.uicomponents.GradientQuadFactory; 54 | import starlingbuilder.extensions.uicomponents.IDisplayObjectFactory; 55 | import starlingbuilder.extensions.uicomponents.ImageFactory; 56 | import starlingbuilder.util.feathers.FeathersUIUtil; 57 | import starlingbuilder.util.ui.inspector.PropertyPanel; 58 | 59 | public class TestApp extends LayoutGroup implements IUIEditorThemeMediator 60 | { 61 | [Embed(source="boostslot_bg_green.png")] 62 | public static const TEXTURE:Class; 63 | 64 | [Embed(source="generic_gift.png")] 65 | public static const ICON:Class; 66 | 67 | public static var texture:Texture; 68 | public static var icon:Texture; 69 | 70 | private static const LINKERS:Array = [DefaultEditPropertyPopup, DisplayObjectPropertyPopup, TexturePropertyPopup, TextureConstructorPopup, ScaleTextureConstructorPopup1]; 71 | 72 | private static const EXTENSIONS:Array = [EmbeddedComponents]; 73 | 74 | /** 75 | * Replace UI factory you would like to test here 76 | */ 77 | public static const SINGLE_COMPONENT:Class = ImageFactory; 78 | 79 | public static const ALL_COMPONENTS:Array = [ImageFactory, ContainerButtonFactory, GradientQuadFactory, GaugeFactory, PixelMaskDisplayObjectFactory, FFParticleSpriteFactory, DBSpriteFactory]; 80 | 81 | public static var TEST_ALL:Boolean = false; 82 | 83 | private var _stage:Stage; 84 | private var _object:DisplayObject; 85 | private var _container:Sprite; 86 | private var _propertyPanel:PropertyPanel; 87 | 88 | public function TestApp() 89 | { 90 | super(); 91 | 92 | _stage = Starling.current.stage; 93 | 94 | width = _stage.stageWidth; 95 | height = _stage.stageHeight; 96 | 97 | layout = new AnchorLayout(); 98 | 99 | _stage.addEventListener(Event.RESIZE, onResize); 100 | 101 | new MetalWorksDesktopTheme2(this); 102 | new TestGameMobileTheme(false, this); 103 | PopUpManager.overlayFactory = BaseMetalWorksDesktopTheme2.popUpOverlayFactory; 104 | 105 | texture = Texture.fromBitmap(new TEXTURE); 106 | icon = Texture.fromBitmap(new ICON); 107 | 108 | setupComponentRenderSupport(); 109 | 110 | 111 | } 112 | 113 | 114 | private function testSingle():void 115 | { 116 | createDisplayObject(SINGLE_COMPONENT); 117 | } 118 | 119 | private function createDisplayObject(cls:Class):void 120 | { 121 | _container.removeChildren(0, -1, true); 122 | 123 | var factory:IDisplayObjectFactory = new cls(); 124 | 125 | _object = factory.create(); 126 | var customParam:Object = factory.customParams; 127 | ComponentRenderSupport.support.extraParamsDict[_object] = customParam; 128 | 129 | _container.addChild(_object); 130 | _propertyPanel.reloadData(_object, ParamUtil.getParams(TemplateData.editor_template, _object), customParam); 131 | } 132 | 133 | private function createPropertyPanel():void 134 | { 135 | mergeTemplates(); 136 | 137 | _propertyPanel = new PropertyPanel(); 138 | 139 | _propertyPanel.layoutData = FeathersUIUtil.anchorLayoutData(50, NaN, NaN, 50); 140 | addChild(_propertyPanel); 141 | } 142 | 143 | private function onResize(event:ResizeEvent):void 144 | { 145 | width = _stage.stageWidth = Starling.current.viewPort.width = event.width; 146 | height = _stage.stageHeight = Starling.current.viewPort.height = event.height; 147 | } 148 | 149 | public function useGameTheme(target:IFeathersControl):Boolean 150 | { 151 | return _container.contains(target as DisplayObject); 152 | } 153 | 154 | private function setupComponentRenderSupport():void 155 | { 156 | var assetManager:AssetManager = new AssetManager(); 157 | assetManager.addTexture("texture", texture); 158 | assetManager.addTexture("icon", icon); 159 | 160 | assetManager.enqueue(File.applicationDirectory.resolvePath("dbanimations")); 161 | 162 | assetManager.loadQueue(function(ratio:Number):void{ 163 | if (ratio == 1) 164 | { 165 | AssetTab.assetList = assetManager.getTextureNames(); 166 | var mediator:IAssetMediator = new DBAssetMediator(assetManager); 167 | var uiBuilder:IUIBuilder = new UIBuilder(mediator, true); 168 | ComponentRenderSupport.support = new ComponentRenderSupport(mediator, new Dictionary(), uiBuilder); 169 | 170 | _container = new Sprite(); 171 | _container.x = 200; 172 | _container.y = 200; 173 | addChild(_container); 174 | 175 | createPropertyPanel(); 176 | 177 | test(); 178 | } 179 | }); 180 | 181 | 182 | } 183 | 184 | private function test():void 185 | { 186 | if (TEST_ALL) 187 | testAll(); 188 | else 189 | testSingle(); 190 | } 191 | 192 | private function testAll(id:int = 0):void 193 | { 194 | createDisplayObject(ALL_COMPONENTS[id]); 195 | 196 | if (++id < ALL_COMPONENTS.length) 197 | { 198 | Starling.current.juggler.delayCall(function():void{ 199 | testAll(id); 200 | }, 0.5); 201 | } 202 | } 203 | 204 | private function mergeTemplates():void 205 | { 206 | for each (var cls:Class in EXTENSIONS) 207 | { 208 | if ("custom_component_template" in cls) 209 | { 210 | var data:Object = new cls.custom_component_template(); 211 | TemplateData.load(JSON.parse(data.toString())); 212 | } 213 | } 214 | } 215 | } 216 | } 217 | -------------------------------------------------------------------------------- /tests/src/boostslot_bg_green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mindjolt/starling-builder-extensions/b3a3fcf1f1c5cbed9d354ba5dab8feed218856fb/tests/src/boostslot_bg_green.png -------------------------------------------------------------------------------- /tests/src/dbanimations/dragon.dat: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 725 | 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | 737 | 738 | 739 | 740 | 741 | 742 | 743 | 744 | 745 | 746 | 747 | 748 | 749 | 750 | 751 | 752 | 753 | 754 | 755 | 756 | 757 | 758 | 759 | -------------------------------------------------------------------------------- /tests/src/dbanimations/dragon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mindjolt/starling-builder-extensions/b3a3fcf1f1c5cbed9d354ba5dab8feed218856fb/tests/src/dbanimations/dragon.png -------------------------------------------------------------------------------- /tests/src/dbanimations/dragon.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /tests/src/generic_gift.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mindjolt/starling-builder-extensions/b3a3fcf1f1c5cbed9d354ba5dab8feed218856fb/tests/src/generic_gift.png -------------------------------------------------------------------------------- /tests/src/starling/extensions/GaugeFactory.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by hyh on 4/20/16. 3 | */ 4 | package starling.extensions 5 | { 6 | import starling.display.DisplayObject; 7 | 8 | import starlingbuilder.extensions.uicomponents.AbstractDisplayObjectFactory; 9 | 10 | public class GaugeFactory extends AbstractDisplayObjectFactory 11 | { 12 | override public function create():DisplayObject 13 | { 14 | return new Gauge(TestApp.texture); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /tests/src/starling/extensions/PixelMaskDisplayObjectFactory.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by hyh on 5/4/16. 3 | */ 4 | package starling.extensions 5 | { 6 | import starling.display.DisplayObject; 7 | import starling.display.Image; 8 | import starling.extensions.pixelmask.PixelMaskDisplayObject; 9 | 10 | import starlingbuilder.extensions.uicomponents.AbstractDisplayObjectFactory; 11 | 12 | public class PixelMaskDisplayObjectFactory extends AbstractDisplayObjectFactory 13 | { 14 | override public function create():DisplayObject 15 | { 16 | var pixelMask:PixelMaskDisplayObject = new PixelMaskDisplayObject(); 17 | pixelMask.pixelMask = new Image(TestApp.icon); 18 | pixelMask.addChild(new Image(TestApp.texture)); 19 | return pixelMask; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/src/starlingbuilder/extensions/animation/DBAssetMediator.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by hyh on 7/25/16. 3 | */ 4 | package starlingbuilder.extensions.animation 5 | { 6 | import dragonBones.animation.WorldClock; 7 | import dragonBones.factories.StarlingFactory; 8 | import dragonBones.objects.DataParser; 9 | import dragonBones.objects.DragonBonesData; 10 | import dragonBones.objects.XMLDataParser; 11 | 12 | import flash.utils.ByteArray; 13 | 14 | import starling.core.Starling; 15 | import starling.events.Event; 16 | 17 | import starling.utils.AssetManager; 18 | 19 | import starlingbuilder.editor.helper.AssetMediator; 20 | 21 | public class DBAssetMediator extends AssetMediator 22 | { 23 | private var _starlingFactory:StarlingFactory; 24 | private var _worldClock:WorldClock; 25 | 26 | public function DBAssetMediator(assetManager:AssetManager) 27 | { 28 | super(assetManager); 29 | 30 | setupDB(); 31 | } 32 | 33 | private function setupDB():void 34 | { 35 | _starlingFactory = new StarlingFactory(); 36 | 37 | var name:String; 38 | var data:DragonBonesData; 39 | 40 | //parse texture atlas 41 | for each (name in _assetManager.getTextureAtlasNames()) 42 | { 43 | _starlingFactory.addTextureAtlas(_assetManager.getTextureAtlas(name), name); 44 | } 45 | 46 | //parse byte array format 47 | for each (name in _assetManager.getByteArrayNames()) 48 | { 49 | if (!_assetManager.getTextureAtlas(name)) continue; 50 | 51 | var ba:ByteArray = _assetManager.getByteArray(name); 52 | 53 | try 54 | { 55 | data = ba.readObject() as DragonBonesData; 56 | } 57 | catch (e:Error) 58 | { 59 | try 60 | { 61 | ba.uncompress(); 62 | data = ba.readObject() as DragonBonesData; 63 | } 64 | catch (e:Error) {} 65 | } 66 | 67 | if (data) 68 | _starlingFactory.addSkeletonData(data, name); 69 | } 70 | 71 | //parse xml format 72 | for each (name in _assetManager.getXmlNames()) 73 | { 74 | if (!_assetManager.getTextureAtlas(name)) continue; 75 | 76 | var xml:XML = _assetManager.getXml(name); 77 | 78 | try 79 | { 80 | data = XMLDataParser.parseDragonBonesData(xml); 81 | _starlingFactory.addSkeletonData(data, name); 82 | } 83 | catch (e:Error) {} 84 | } 85 | 86 | //parse json format 87 | for each (name in _assetManager.getObjectNames()) 88 | { 89 | if (!_assetManager.getTextureAtlas(name)) continue; 90 | 91 | var object:Object = _assetManager.getObject(name); 92 | 93 | try 94 | { 95 | data = DataParser.parseData(object); 96 | _starlingFactory.addSkeletonData(data, name); 97 | } 98 | catch (e:Error) {} 99 | } 100 | 101 | _worldClock = new WorldClock(); 102 | Starling.current.stage.addEventListener(Event.ENTER_FRAME, onEnterFrame); 103 | } 104 | 105 | private function onEnterFrame(event:Event):void 106 | { 107 | _worldClock.advanceTime(-1); 108 | } 109 | 110 | override public function getCustomData(type:String, name:String):Object 111 | { 112 | switch (type) 113 | { 114 | case DBSprite.STARLING_FACTORY: 115 | return _starlingFactory; 116 | case DBSprite.WORLD_CLOCK: 117 | return _worldClock; 118 | default: 119 | return null; 120 | } 121 | } 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /tests/src/starlingbuilder/extensions/animation/DBSpriteFactory.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by hyh on 7/25/16. 3 | */ 4 | package starlingbuilder.extensions.animation 5 | { 6 | import starling.display.DisplayObject; 7 | 8 | import starlingbuilder.editor.controller.ComponentRenderSupport; 9 | import starlingbuilder.extensions.uicomponents.AbstractDisplayObjectFactory; 10 | 11 | public class DBSpriteFactory extends AbstractDisplayObjectFactory 12 | { 13 | override public function create():DisplayObject 14 | { 15 | var sprite:DBSprite = new DBSprite(ComponentRenderSupport.support.assetMediator); 16 | sprite.y = 250; 17 | sprite.armatureName = "Dragon"; 18 | sprite.animationName = "walk"; 19 | sprite.autoPlay = true; 20 | return sprite; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /tests/src/starlingbuilder/extensions/particle/FFParticleSpriteFactory.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by hyh on 4/30/16. 3 | */ 4 | package starlingbuilder.extensions.particle 5 | { 6 | import starling.display.DisplayObject; 7 | import starling.textures.Texture; 8 | 9 | import starlingbuilder.extensions.uicomponents.AbstractDisplayObjectFactory; 10 | 11 | public class FFParticleSpriteFactory extends AbstractDisplayObjectFactory 12 | { 13 | [Embed(source="default.png")] 14 | public static const TEXTURE:Class; 15 | 16 | [Embed(source="default.pex", mimeType="application/octet-stream")] 17 | public static const CONFIG:Class; 18 | 19 | override public function create():DisplayObject 20 | { 21 | var sprite:FFParticleSprite = new FFParticleSprite(); 22 | sprite.texture = Texture.fromBitmap(new TEXTURE); 23 | sprite.config = XML(new CONFIG()); 24 | sprite.particleId = "particle1"; 25 | return sprite; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /tests/src/starlingbuilder/extensions/particle/default.pex: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /tests/src/starlingbuilder/extensions/particle/default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mindjolt/starling-builder-extensions/b3a3fcf1f1c5cbed9d354ba5dab8feed218856fb/tests/src/starlingbuilder/extensions/particle/default.png -------------------------------------------------------------------------------- /tests/src/starlingbuilder/extensions/uicomponents/AbstractDisplayObjectFactory.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by hyh on 7/19/16. 3 | */ 4 | package starlingbuilder.extensions.uicomponents 5 | { 6 | import starling.display.DisplayObject; 7 | 8 | public class AbstractDisplayObjectFactory implements IDisplayObjectFactory 9 | { 10 | public function create():DisplayObject 11 | { 12 | return null; 13 | } 14 | 15 | public function get customParams():Object 16 | { 17 | return { 18 | cls:"", 19 | constructorParams:[], 20 | params:{}, 21 | customParams:{} 22 | }; 23 | } 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /tests/src/starlingbuilder/extensions/uicomponents/ContainerButtonFactory.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by hyh on 3/3/16. 3 | */ 4 | package starlingbuilder.extensions.uicomponents 5 | { 6 | import starling.core.Starling; 7 | import starling.display.DisplayObject; 8 | import starling.display.Image; 9 | import starling.events.Event; 10 | 11 | public class ContainerButtonFactory extends AbstractDisplayObjectFactory 12 | { 13 | override public function create():DisplayObject 14 | { 15 | var button:ContainerButton = new ContainerButton(); 16 | button.addEventListener(Event.TRIGGERED, onClick); 17 | var img1:Image = new Image(TestApp.texture); 18 | var img2:Image = new Image(TestApp.icon); 19 | img1.y = img2.y = 100; 20 | button.addChild(img1); 21 | button.addChild(img2); 22 | button.alignPivot(); 23 | Starling.juggler.tween(button, 1, {"scaleX":0.9, "scaleY":0.9, "repeatCount":0, "reverse":true}); 24 | return button; 25 | } 26 | 27 | private function onClick(event:Event):void 28 | { 29 | trace("on click"); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /tests/src/starlingbuilder/extensions/uicomponents/GradientQuadFactory.as: -------------------------------------------------------------------------------- 1 | package starlingbuilder.extensions.uicomponents 2 | { 3 | import starling.display.DisplayObject; 4 | import starling.utils.Color; 5 | 6 | /** 7 | *author WG 8 | *2016-3-9 9 | */ 10 | public class GradientQuadFactory extends AbstractDisplayObjectFactory 11 | { 12 | override public function create():DisplayObject 13 | { 14 | var quad:GradientQuad = new GradientQuad(150, 150); 15 | quad.topLeftColor = Color.WHITE; 16 | quad.topRightColor = Color.RED; 17 | quad.bottomLeftColor = Color.GREEN; 18 | quad.bottomRightColor = Color.BLUE; 19 | return quad; 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /tests/src/starlingbuilder/extensions/uicomponents/IDisplayObjectFactory.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by hyh on 3/3/16. 3 | */ 4 | package starlingbuilder.extensions.uicomponents 5 | { 6 | import starling.display.DisplayObject; 7 | 8 | public interface IDisplayObjectFactory 9 | { 10 | function create():DisplayObject; 11 | 12 | function get customParams():Object; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/src/starlingbuilder/extensions/uicomponents/ImageFactory.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by hyh on 3/3/16. 3 | */ 4 | package starlingbuilder.extensions.uicomponents 5 | { 6 | import starling.display.DisplayObject; 7 | import starling.display.Image; 8 | 9 | public class ImageFactory extends AbstractDisplayObjectFactory 10 | { 11 | override public function create():DisplayObject 12 | { 13 | return new Image(TestApp.texture); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /theme/assets/fonts/SourceSansPro-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mindjolt/starling-builder-extensions/b3a3fcf1f1c5cbed9d354ba5dab8feed218856fb/theme/assets/fonts/SourceSansPro-Regular.ttf -------------------------------------------------------------------------------- /theme/assets/fonts/SourceSansPro-Semibold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mindjolt/starling-builder-extensions/b3a3fcf1f1c5cbed9d354ba5dab8feed218856fb/theme/assets/fonts/SourceSansPro-Semibold.ttf -------------------------------------------------------------------------------- /theme/assets/images/metalworks_mobile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mindjolt/starling-builder-extensions/b3a3fcf1f1c5cbed9d354ba5dab8feed218856fb/theme/assets/images/metalworks_mobile.png -------------------------------------------------------------------------------- /theme/assets/images/metalworks_mobile.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /theme/src/EmbeddedTheme.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by hyh on 7/30/15. 3 | */ 4 | package 5 | { 6 | import feathers.themes.TestGameMobileTheme; 7 | 8 | import flash.display.Sprite; 9 | 10 | public class EmbeddedTheme extends Sprite 11 | { 12 | public static const theme:Class = TestGameMobileTheme 13 | 14 | public function EmbeddedTheme() 15 | { 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /theme/src/feathers/themes/TestGameMobileTheme.as: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2012-2015 Joshua Tynjala 3 | 4 | Permission is hereby granted, free of charge, to any person 5 | obtaining a copy of this software and associated documentation 6 | files (the "Software"), to deal in the Software without 7 | restriction, including without limitation the rights to use, 8 | copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the 10 | Software is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | package feathers.themes 26 | { 27 | import starlingbuilder.editor.themes.IUIEditorThemeMediator; 28 | 29 | import flash.display.Bitmap; 30 | import flash.display.BitmapData; 31 | 32 | import starling.events.Event; 33 | import starling.textures.Texture; 34 | import starling.textures.TextureAtlas; 35 | 36 | /** 37 | * The "Metal Works" theme for mobile Feathers apps. 38 | * 39 | *

This version of the theme embeds its assets. To load assets at 40 | * runtime, see MetalWorksMobileThemeWithAssetManager instead.

41 | * 42 | * @see http://feathersui.com/help/theme-assets.html 43 | */ 44 | public class TestGameMobileTheme extends BaseTestGameMobileTheme 45 | { 46 | /** 47 | * @private 48 | */ 49 | [Embed(source="../../../assets/images/metalworks_mobile.xml",mimeType="application/octet-stream")] 50 | protected static const ATLAS_XML:Class; 51 | 52 | /** 53 | * @private 54 | */ 55 | [Embed(source="../../../assets/images/metalworks_mobile.png")] 56 | protected static const ATLAS_BITMAP:Class; 57 | 58 | /** 59 | * Constructor. 60 | */ 61 | public function TestGameMobileTheme(scaleToDPI:Boolean = true, themeMediator:IUIEditorThemeMediator = null) 62 | { 63 | super(scaleToDPI, themeMediator); 64 | this.initialize(); 65 | this.dispatchEventWith(Event.COMPLETE); 66 | } 67 | 68 | /** 69 | * @private 70 | */ 71 | override protected function initialize():void 72 | { 73 | this.initializeTextureAtlas(); 74 | super.initialize(); 75 | } 76 | 77 | /** 78 | * @private 79 | */ 80 | protected function initializeTextureAtlas():void 81 | { 82 | var atlasBitmapData:BitmapData = Bitmap(new ATLAS_BITMAP()).bitmapData; 83 | var atlasTexture:Texture = Texture.fromBitmapData(atlasBitmapData, false); 84 | atlasTexture.root.onRestore = this.atlasTexture_onRestore; 85 | atlasBitmapData.dispose(); 86 | this.atlas = new TextureAtlas(atlasTexture, XML(new ATLAS_XML())); 87 | } 88 | 89 | /** 90 | * @private 91 | */ 92 | protected function atlasTexture_onRestore():void 93 | { 94 | var atlasBitmapData:BitmapData = Bitmap(new ATLAS_BITMAP()).bitmapData; 95 | this.atlas.texture.root.uploadBitmapData(atlasBitmapData); 96 | atlasBitmapData.dispose(); 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /ui-components/src/EmbeddedComponents.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by hyh on 9/29/15. 3 | */ 4 | package 5 | { 6 | import flash.display.Sprite; 7 | 8 | import starling.extensions.Gauge; 9 | 10 | import starling.extensions.pixelmask.PixelMaskDisplayObject; 11 | 12 | import starlingbuilder.extensions.animation.DBAssetMediator; 13 | 14 | import starlingbuilder.extensions.animation.DBSprite; 15 | 16 | import starlingbuilder.extensions.particle.FFParticleSprite; 17 | 18 | import starlingbuilder.extensions.uicomponents.ContainerButton; 19 | import starlingbuilder.extensions.uicomponents.GradientQuad; 20 | 21 | public class EmbeddedComponents extends Sprite 22 | { 23 | [Embed(source="custom_component_template.json", mimeType="application/octet-stream")] 24 | public static const custom_component_template:Class; 25 | 26 | public static const linkers:Array = [PixelMaskDisplayObject, ContainerButton, GradientQuad, Gauge, FFParticleSprite, DBSprite, DBAssetMediator]; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ui-components/src/custom_component_template.json: -------------------------------------------------------------------------------- 1 | { 2 | "custom_components":[ 3 | 4 | { 5 | "cls":"starlingbuilder.extensions.uicomponents.ContainerButton", 6 | "params":[ 7 | {"name":"width", "min":0, "read_only":true, "link":true}, 8 | {"name":"height", "min":0, "read_only":true, "link":true}, 9 | {"name":"scaleX", "step":0.01, "default_value":1}, 10 | {"name":"scaleY", "step":0.01, "default_value":1}, 11 | {"name":"scaleWhenDown", "step":0.01, "default_value":0.9}, 12 | {"name":"scaleWhenOver", "step":0.01, "default_value":1} 13 | ], 14 | "container":true, 15 | "tag":"container" 16 | }, 17 | 18 | { 19 | "cls":"starling.extensions.pixelmask.PixelMaskDisplayObject", 20 | "params":[ 21 | {"name":"pixelMask", "component":"popup", "cls":true, "disable":true, "default_value":null, "editPropertyClass":"starlingbuilder.editor.ui.DisplayObjectPropertyPopup"}, 22 | {"name":"isAnimated", "component":"check", "default_value":true}, 23 | {"name":"inverted", "component":"check", "default_value":false} 24 | ], 25 | "container":true, 26 | "tag":"container" 27 | }, 28 | 29 | { 30 | "cls":"starlingbuilder.extensions.uicomponents.GradientQuad", 31 | "params":[ 32 | {"name":"width", "min":0, "read_only":true, "link":true}, 33 | {"name":"height", "min":0, "read_only":true, "link":true}, 34 | {"name":"scaleX", "step":0.01, "default_value":1}, 35 | {"name":"scaleY", "step":0.01, "default_value":1}, 36 | {"name":"topLeftColor", "component":"colorPicker", "default_value":16777215}, 37 | {"name":"topRightColor", "component":"colorPicker", "default_value":16777215}, 38 | {"name":"bottomLeftColor", "component":"colorPicker", "default_value":16777215}, 39 | {"name":"bottomRightColor", "component":"colorPicker", "default_value":16777215} 40 | ], 41 | "constructorParams": 42 | [ 43 | {"type":"Number", "value":50}, 44 | {"type":"Number", "value":50} 45 | ], 46 | "createButton":true, 47 | "tag":"asset" 48 | }, 49 | 50 | { 51 | "cls":"starling.extensions.Gauge", 52 | "constructorParams": 53 | [ 54 | {"cls":"starling.textures.Texture"} 55 | ], 56 | "params":[ 57 | {"name":"width", "min":0, "read_only":true, "link":true}, 58 | {"name":"height", "min":0, "read_only":true, "link":true}, 59 | {"name":"scaleX", "step":0.01, "default_value":1}, 60 | {"name":"scaleY", "step":0.01, "default_value":1}, 61 | {"name":"ratio", "component":"slider", "step":0.01, "min":0, "max":1, "default_value":1} 62 | ], 63 | "tag":"asset" 64 | }, 65 | 66 | { 67 | "cls":"starlingbuilder.extensions.particle.FFParticleSprite", 68 | "params":[ 69 | {"name":"particleId", "default_value":null}, 70 | {"name":"texture", "component":"popup", "cls":true, "disable":true, "default_value":null, "editPropertyClass":"starlingbuilder.editor.ui.TexturePropertyPopup"}, 71 | {"name":"config", "component":"popup", "cls":true, "disable":true, "default_value":null, "editPropertyClass":"starlingbuilder.editor.ui.XmlPropertyPopup"}, 72 | {"name":"cacheParticle", "component":"check", "default_value":true} 73 | ], 74 | "customParams":{}, 75 | "tag":"container" 76 | }, 77 | 78 | { 79 | "cls":"starlingbuilder.extensions.animation.DBSprite", 80 | "constructorParams": 81 | [ 82 | {"cls":"starlingbuilder.engine.IAssetMediator"} 83 | ], 84 | "params":[ 85 | {"name":"armatureName", "default_value":null}, 86 | {"name":"animationName", "default_value":null}, 87 | {"name":"autoPlay", "component":"check", "default_value":false} 88 | ], 89 | "customParams":{}, 90 | "tag":"container" 91 | } 92 | ] 93 | } 94 | -------------------------------------------------------------------------------- /ui-components/src/starling/extensions/Gauge.as: -------------------------------------------------------------------------------- 1 | package starling.extensions 2 | { 3 | import flash.geom.Point; 4 | 5 | import starling.display.Image; 6 | import starling.display.Sprite; 7 | import starling.textures.Texture; 8 | 9 | public class Gauge extends Sprite 10 | { 11 | private var _image:Image; 12 | private var _ratio:Number; 13 | 14 | public function Gauge(texture:Texture) 15 | { 16 | _ratio = 1.0; 17 | _image = new Image(texture); 18 | 19 | addChild(_image); 20 | } 21 | 22 | private function update():void 23 | { 24 | _image.scaleX = _ratio; 25 | _image.setTexCoords(1, new Point(_ratio, 0)); 26 | _image.setTexCoords(3, new Point(_ratio, 1)); 27 | } 28 | 29 | public function get ratio():Number { return _ratio; } 30 | public function set ratio(value:Number):void 31 | { 32 | _ratio = value > 1 ? 1 : (value < 0 ? 0 : value); 33 | update(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /ui-components/src/starling/extensions/pixelmask/PixelMaskDisplayObject.as: -------------------------------------------------------------------------------- 1 | package starling.extensions.pixelmask 2 | { 3 | import flash.display3D.Context3DBlendFactor; 4 | import flash.geom.Matrix; 5 | 6 | import starling.core.RenderSupport; 7 | import starling.core.Starling; 8 | import starling.display.BlendMode; 9 | import starling.display.DisplayObject; 10 | import starling.display.DisplayObjectContainer; 11 | import starling.display.Image; 12 | import starling.events.Event; 13 | import starling.textures.RenderTexture; 14 | 15 | public class PixelMaskDisplayObject extends DisplayObjectContainer 16 | { 17 | private static const MASK_MODE_NORMAL:String = "mask"; 18 | private static const MASK_MODE_INVERTED:String = "maskinverted"; 19 | 20 | private var _pixelMask:DisplayObject; 21 | private var _renderTexture:RenderTexture; 22 | private var _maskRenderTexture:RenderTexture; 23 | 24 | private var _image:Image; 25 | private var _maskImage:Image; 26 | 27 | private var _superRenderFlag:Boolean = false; 28 | private var _inverted:Boolean = false; 29 | private var _scaleFactor:Number; 30 | private var _isAnimated:Boolean = true; 31 | private var _maskRendered:Boolean = false; 32 | 33 | public function PixelMaskDisplayObject(scaleFactor:Number=-1, isAnimated:Boolean=true) 34 | { 35 | super(); 36 | 37 | _isAnimated = isAnimated; 38 | _scaleFactor = scaleFactor; 39 | 40 | BlendMode.register(MASK_MODE_NORMAL, Context3DBlendFactor.ZERO, Context3DBlendFactor.SOURCE_ALPHA); 41 | BlendMode.register(MASK_MODE_INVERTED, Context3DBlendFactor.ZERO, Context3DBlendFactor.ONE_MINUS_SOURCE_ALPHA); 42 | 43 | // Handle lost context. By using the conventional event, we can make a weak listener. 44 | // This avoids memory leaks when people forget to call "dispose" on the object. 45 | Starling.current.stage3D.addEventListener(Event.CONTEXT3D_CREATE, 46 | onContextCreated, false, 0, true); 47 | } 48 | 49 | public function get isAnimated():Boolean 50 | { 51 | return _isAnimated; 52 | } 53 | 54 | public function set isAnimated(value:Boolean):void 55 | { 56 | _isAnimated = value; 57 | } 58 | 59 | override public function dispose():void 60 | { 61 | clearRenderTextures(); 62 | Starling.current.stage3D.removeEventListener(Event.CONTEXT3D_CREATE, onContextCreated); 63 | super.dispose(); 64 | } 65 | 66 | private function onContextCreated(event:Object):void 67 | { 68 | refreshRenderTextures(); 69 | } 70 | 71 | public function get inverted():Boolean 72 | { 73 | return _inverted; 74 | } 75 | 76 | public function set inverted(value:Boolean):void 77 | { 78 | _inverted = value; 79 | refreshRenderTextures(null); 80 | } 81 | 82 | public function set pixelMask(mask:DisplayObject) : void 83 | { 84 | 85 | // clean up existing mask if there is one 86 | if (_pixelMask) { 87 | _pixelMask = null; 88 | } 89 | 90 | if (mask) { 91 | _pixelMask = mask; 92 | 93 | if (_pixelMask.width==0 || _pixelMask.height==0) { 94 | throw new Error ("Mask must have dimensions. Current dimensions are " + _pixelMask.width + "x" + _pixelMask.height + "."); 95 | } 96 | 97 | refreshRenderTextures(null); 98 | } else { 99 | clearRenderTextures(); 100 | } 101 | } 102 | 103 | public function get pixelMask():DisplayObject 104 | { 105 | return _pixelMask; 106 | } 107 | 108 | private function clearRenderTextures() : void 109 | { 110 | // clean up old render textures and images 111 | if (_maskRenderTexture) { 112 | _maskRenderTexture.dispose(); 113 | } 114 | 115 | if (_renderTexture) { 116 | _renderTexture.dispose(); 117 | } 118 | 119 | if (_image) { 120 | _image.dispose(); 121 | } 122 | 123 | if (_maskImage) { 124 | _maskImage.dispose(); 125 | } 126 | } 127 | 128 | private function refreshRenderTextures(e:Event=null) : void 129 | { 130 | if (_pixelMask) { 131 | 132 | clearRenderTextures(); 133 | 134 | _maskRenderTexture = new RenderTexture(_pixelMask.width, _pixelMask.height, false, _scaleFactor); 135 | _renderTexture = new RenderTexture(_pixelMask.width, _pixelMask.height, false, _scaleFactor); 136 | 137 | // create image with the new render texture 138 | _image = new Image(_renderTexture); 139 | 140 | // create image to blit the mask onto 141 | _maskImage = new Image(_maskRenderTexture); 142 | 143 | // set the blending mode to MASK (ZERO, SRC_ALPHA) 144 | if (_inverted) { 145 | _maskImage.blendMode = MASK_MODE_INVERTED; 146 | } else { 147 | _maskImage.blendMode = MASK_MODE_NORMAL; 148 | } 149 | } 150 | _maskRendered = false; 151 | } 152 | 153 | public override function render(support:RenderSupport, parentAlpha:Number):void 154 | { 155 | if (_isAnimated || (!_isAnimated && !_maskRendered)) { 156 | if (_superRenderFlag || !_pixelMask) { 157 | super.render(support, parentAlpha); 158 | } else { 159 | if (_pixelMask) { 160 | _maskRenderTexture.draw(_pixelMask); 161 | _renderTexture.drawBundled(drawRenderTextures); 162 | _image.render(support, parentAlpha); 163 | _maskRendered = true; 164 | } 165 | } 166 | } else { 167 | _image.render(support, parentAlpha); 168 | } 169 | } 170 | 171 | private static var _a:Number; 172 | private static var _b:Number; 173 | private static var _c:Number; 174 | private static var _d:Number; 175 | private static var _tx:Number; 176 | private static var _ty:Number; 177 | 178 | private function drawRenderTextures(object:DisplayObject=null, matrix:Matrix=null, alpha:Number=1.0) : void 179 | { 180 | _a = this.transformationMatrix.a; 181 | _b = this.transformationMatrix.b; 182 | _c = this.transformationMatrix.c; 183 | _d = this.transformationMatrix.d; 184 | 185 | _tx = this.transformationMatrix.tx; 186 | _ty = this.transformationMatrix.ty; 187 | 188 | this.transformationMatrix.a = 1; 189 | this.transformationMatrix.b = 0; 190 | this.transformationMatrix.c = 0; 191 | this.transformationMatrix.d = 1; 192 | 193 | this.transformationMatrix.tx = 0; 194 | this.transformationMatrix.ty = 0; 195 | 196 | _superRenderFlag = true; 197 | _renderTexture.draw(this); 198 | _superRenderFlag = false; 199 | 200 | this.transformationMatrix.a = _a; 201 | this.transformationMatrix.b = _b; 202 | this.transformationMatrix.c = _c; 203 | this.transformationMatrix.d = _d; 204 | 205 | this.transformationMatrix.tx = _tx; 206 | this.transformationMatrix.ty = _ty; 207 | 208 | _renderTexture.draw(_maskImage); 209 | } 210 | } 211 | } -------------------------------------------------------------------------------- /ui-components/src/starlingbuilder/extensions/animation/DBSprite.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by hyh on 7/25/16. 3 | */ 4 | package starlingbuilder.extensions.animation 5 | { 6 | import dragonBones.Armature; 7 | import dragonBones.animation.WorldClock; 8 | import dragonBones.factories.StarlingFactory; 9 | 10 | import starling.display.DisplayObject; 11 | 12 | import starling.display.Sprite; 13 | 14 | import starlingbuilder.engine.IAssetMediator; 15 | 16 | public class DBSprite extends Sprite 17 | { 18 | public static const STARLING_FACTORY:String = "starlingFactory"; 19 | public static const WORLD_CLOCK:String = "worldClock"; 20 | 21 | protected var _assetMediator:IAssetMediator; 22 | protected var _starlingFactory:StarlingFactory; 23 | protected var _worldClock:WorldClock; 24 | 25 | protected var _armatureName:String; 26 | protected var _animationName:String; 27 | 28 | protected var _armature:Armature; 29 | protected var _autoPlay:Boolean = false; 30 | 31 | public function DBSprite(assetMediator:IAssetMediator) 32 | { 33 | super(); 34 | _assetMediator = assetMediator; 35 | _starlingFactory = _assetMediator.getCustomData("starlingFactory", null) as StarlingFactory; 36 | _worldClock = _assetMediator.getCustomData("worldClock", null) as WorldClock; 37 | } 38 | 39 | public function get armatureName():String 40 | { 41 | return _armatureName; 42 | } 43 | 44 | public function set armatureName(value:String):void 45 | { 46 | if (_armatureName != value) 47 | { 48 | _armatureName = value; 49 | play(); 50 | } 51 | } 52 | 53 | public function get animationName():String 54 | { 55 | return _animationName; 56 | } 57 | 58 | public function set animationName(value:String):void 59 | { 60 | if (_animationName != value) 61 | { 62 | _animationName = value; 63 | play(); 64 | } 65 | } 66 | 67 | public function get autoPlay():Boolean 68 | { 69 | return _autoPlay; 70 | } 71 | 72 | public function set autoPlay(value:Boolean):void 73 | { 74 | if (_autoPlay != value) 75 | { 76 | _autoPlay = value; 77 | play(); 78 | } 79 | } 80 | 81 | public function play():void 82 | { 83 | if (_armatureName && _animationName && _autoPlay) 84 | { 85 | disposeArmature(); 86 | createArmature(); 87 | _armature.animation.gotoAndPlay(_animationName); 88 | } 89 | } 90 | 91 | protected function disposeArmature():void 92 | { 93 | if (_armature) 94 | { 95 | (_armature.display as DisplayObject).removeFromParent(true); 96 | _worldClock.remove(_armature); 97 | _armature.dispose(); 98 | _armature = null; 99 | } 100 | } 101 | 102 | protected function createArmature():void 103 | { 104 | if (!_animationName) return; 105 | 106 | _armature = _starlingFactory.buildArmature(_armatureName); 107 | 108 | if (_armature) 109 | { 110 | _worldClock.add(_armature); 111 | addChild(_armature.display as DisplayObject); 112 | } 113 | } 114 | 115 | public function get armature():Armature 116 | { 117 | return _armature; 118 | } 119 | 120 | override public function dispose():void 121 | { 122 | disposeArmature(); 123 | super.dispose(); 124 | } 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /ui-components/src/starlingbuilder/extensions/uicomponents/ContainerButton.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by hyh on 4/24/16. 3 | */ 4 | package starlingbuilder.extensions.uicomponents 5 | { 6 | import flash.geom.Rectangle; 7 | import flash.ui.Mouse; 8 | import flash.ui.MouseCursor; 9 | 10 | import starling.display.ButtonState; 11 | import starling.display.DisplayObject; 12 | 13 | import starling.display.DisplayObjectContainer; 14 | import starling.display.Sprite; 15 | 16 | import starling.events.Event; 17 | import starling.events.Touch; 18 | import starling.events.TouchEvent; 19 | import starling.events.TouchPhase; 20 | 21 | import starlingbuilder.engine.util.DisplayObjectUtil; 22 | 23 | /** Dispatched when the user triggers the button. Bubbles. */ 24 | [Event(name="triggered", type="starling.events.Event")] 25 | 26 | /** 27 | * A button as a container, you can layout whatever you want inside ContainerButton 28 | */ 29 | public class ContainerButton extends DisplayObjectContainer 30 | { 31 | private static const MAX_DRAG_DIST:Number = 50; 32 | 33 | private static var sRect:Rectangle = new Rectangle(); 34 | 35 | private var mContents:Sprite; 36 | 37 | private var mScaleWhenDown:Number; 38 | private var mScaleWhenOver:Number; 39 | private var mAlphaWhenDown:Number; 40 | private var mAlphaWhenDisabled:Number; 41 | private var mUseHandCursor:Boolean; 42 | private var mEnabled:Boolean; 43 | private var mState:String; 44 | private var mTriggerBounds:Rectangle; 45 | 46 | /** Creates a button with a set of state-textures and (optionally) some text. 47 | * Any state that is left 'null' will display the up-state texture. Beware that all 48 | * state textures should have the same dimensions. */ 49 | public function ContainerButton() 50 | { 51 | mState = ButtonState.UP; 52 | mScaleWhenDown = 0.9; 53 | mScaleWhenOver = mAlphaWhenDown = 1.0; 54 | mAlphaWhenDisabled = 0.5; 55 | mEnabled = true; 56 | mUseHandCursor = true; 57 | mTriggerBounds = new Rectangle(); 58 | 59 | mContents = new Sprite(); 60 | super.addChildAt(mContents, 0); 61 | addEventListener(TouchEvent.TOUCH, onTouch); 62 | } 63 | 64 | /** @inheritDoc */ 65 | public override function dispose():void 66 | { 67 | mContents.dispose(); 68 | super.dispose(); 69 | } 70 | 71 | private function onTouch(event:TouchEvent):void 72 | { 73 | Mouse.cursor = (mUseHandCursor && mEnabled && event.interactsWith(this)) ? 74 | MouseCursor.BUTTON : MouseCursor.AUTO; 75 | 76 | var touch:Touch = event.getTouch(this); 77 | var isWithinBounds:Boolean; 78 | 79 | if (!mEnabled) 80 | { 81 | return; 82 | } 83 | else if (touch == null) 84 | { 85 | state = ButtonState.UP; 86 | } 87 | else if (touch.phase == TouchPhase.HOVER) 88 | { 89 | state = ButtonState.OVER; 90 | } 91 | else if (touch.phase == TouchPhase.BEGAN && mState != ButtonState.DOWN) 92 | { 93 | mTriggerBounds = getBounds(stage, mTriggerBounds); 94 | mTriggerBounds.inflate(MAX_DRAG_DIST, MAX_DRAG_DIST); 95 | 96 | state = ButtonState.DOWN; 97 | } 98 | else if (touch.phase == TouchPhase.MOVED) 99 | { 100 | isWithinBounds = mTriggerBounds.contains(touch.globalX, touch.globalY); 101 | 102 | if (mState == ButtonState.DOWN && !isWithinBounds) 103 | { 104 | // reset button when finger is moved too far away ... 105 | state = ButtonState.UP; 106 | } 107 | else if (mState == ButtonState.UP && isWithinBounds) 108 | { 109 | // ... and reactivate when the finger moves back into the bounds. 110 | state = ButtonState.DOWN; 111 | } 112 | } 113 | else if (touch.phase == TouchPhase.ENDED && mState == ButtonState.DOWN) 114 | { 115 | state = ButtonState.UP; 116 | if (!touch.cancelled) dispatchEventWith(Event.TRIGGERED, true); 117 | } 118 | } 119 | 120 | /** The current state of the button. The corresponding strings are found 121 | * in the ButtonState class. */ 122 | public function get state():String { return mState; } 123 | public function set state(value:String):void 124 | { 125 | mState = value; 126 | refreshState(); 127 | } 128 | 129 | private function refreshState():void 130 | { 131 | mContents.x = mContents.y = 0; 132 | mContents.scaleX = mContents.scaleY = mContents.alpha = 1.0; 133 | mContents.getBounds(this, sRect); 134 | 135 | switch (mState) 136 | { 137 | case ButtonState.DOWN: 138 | mContents.alpha = mAlphaWhenDown; 139 | mContents.scaleX = mContents.scaleY = mScaleWhenDown; 140 | mContents.x = (1 - mScaleWhenDown) * (sRect.x + sRect.width * 0.5); 141 | mContents.y = (1 - mScaleWhenDown) * (sRect.y + sRect.height * 0.5); 142 | break; 143 | case ButtonState.UP: 144 | break; 145 | case ButtonState.OVER: 146 | mContents.scaleX = mContents.scaleY = mScaleWhenOver; 147 | mContents.x = (1 - mScaleWhenOver) * (sRect.x + sRect.width * 0.5); 148 | mContents.y = (1 - mScaleWhenOver) * (sRect.y + sRect.height * 0.5); 149 | break; 150 | case ButtonState.DISABLED: 151 | mContents.alpha = mAlphaWhenDisabled; 152 | break; 153 | default: 154 | throw new ArgumentError("Invalid button state: " + mState); 155 | } 156 | } 157 | 158 | 159 | 160 | /** The scale factor of the button on touch. Per default, a button without a down state 161 | * texture will be made slightly smaller, while a button with a down state texture 162 | * remains unscaled. */ 163 | public function get scaleWhenDown():Number { return mScaleWhenDown; } 164 | public function set scaleWhenDown(value:Number):void 165 | { 166 | mScaleWhenDown = value; 167 | if (mState == ButtonState.DOWN) refreshState(); 168 | } 169 | 170 | /** The scale factor of the button while the mouse cursor hovers over it. @default 1.0 */ 171 | public function get scaleWhenOver():Number { return mScaleWhenOver; } 172 | public function set scaleWhenOver(value:Number):void 173 | { 174 | mScaleWhenOver = value; 175 | if (mState == ButtonState.OVER) refreshState(); 176 | } 177 | 178 | /** The alpha value of the button on touch. @default 1.0 */ 179 | public function get alphaWhenDown():Number { return mAlphaWhenDown; } 180 | public function set alphaWhenDown(value:Number):void 181 | { 182 | mAlphaWhenDown = value; 183 | if (mState == ButtonState.DOWN) refreshState(); 184 | } 185 | 186 | /** The alpha value of the button when it is disabled. @default 0.5 */ 187 | public function get alphaWhenDisabled():Number { return mAlphaWhenDisabled; } 188 | public function set alphaWhenDisabled(value:Number):void 189 | { 190 | mAlphaWhenDisabled = value; 191 | if (mState == ButtonState.DISABLED) refreshState(); 192 | } 193 | 194 | /** Indicates if the button can be triggered. */ 195 | public function get enabled():Boolean { return mEnabled; } 196 | public function set enabled(value:Boolean):void 197 | { 198 | if (mEnabled != value) 199 | { 200 | mEnabled = value; 201 | state = value ? ButtonState.UP : ButtonState.DISABLED; 202 | } 203 | } 204 | 205 | /** Indicates if the mouse cursor should transform into a hand while it's over the button. 206 | * @default true */ 207 | public override function get useHandCursor():Boolean { return mUseHandCursor; } 208 | public override function set useHandCursor(value:Boolean):void { mUseHandCursor = value; } 209 | 210 | override public function get numChildren():int 211 | { 212 | return mContents.numChildren; 213 | } 214 | 215 | override public function getChildByName(name:String):DisplayObject 216 | { 217 | return mContents.getChildByName(name); 218 | } 219 | 220 | override public function getChildAt(index:int):DisplayObject 221 | { 222 | return mContents.getChildAt(index); 223 | } 224 | 225 | override public function addChild(child:DisplayObject):DisplayObject 226 | { 227 | return mContents.addChild(child); 228 | } 229 | 230 | override public function addChildAt(child:DisplayObject, index:int):DisplayObject 231 | { 232 | return mContents.addChildAt(child, index); 233 | } 234 | 235 | override public function removeChildAt(index:int, dispose:Boolean = false):DisplayObject 236 | { 237 | return mContents.removeChildAt(index, dispose); 238 | } 239 | 240 | override public function getChildIndex(child:DisplayObject):int 241 | { 242 | return mContents.getChildIndex(child); 243 | } 244 | 245 | override public function setChildIndex(child:DisplayObject, index:int):void 246 | { 247 | mContents.setChildIndex(child, index); 248 | } 249 | 250 | override public function swapChildrenAt(index1:int,index2:int):void 251 | { 252 | mContents.swapChildrenAt(index1, index2); 253 | } 254 | 255 | override public function sortChildren(compareFunction:Function):void 256 | { 257 | mContents.sortChildren(compareFunction); 258 | } 259 | } 260 | } -------------------------------------------------------------------------------- /ui-components/src/starlingbuilder/extensions/uicomponents/GradientQuad.as: -------------------------------------------------------------------------------- 1 | package starlingbuilder.extensions.uicomponents 2 | { 3 | import starling.display.Quad; 4 | /** 5 | *颜色渐变的quad 6 | *author WG 7 | *2016-3-7 8 | */ 9 | public class GradientQuad extends Quad 10 | { 11 | private var _topLeftColor:uint; 12 | private var _topRightColor:uint; 13 | private var _bottomLeftColor:uint; 14 | private var _bottomRightColor:uint; 15 | public function GradientQuad(width:Number, height:Number, color:uint=0xffffff, premultipliedAlpha:Boolean=true ):void 16 | { 17 | super(width, height, color, premultipliedAlpha); 18 | 19 | _topLeftColor = _topRightColor = _bottomLeftColor = _bottomRightColor = 0xffffff; 20 | } 21 | public function set topLeftColor(value:uint):void 22 | { 23 | _topLeftColor = value; 24 | setVertexColor(0, value); 25 | } 26 | public function set topRightColor(value:uint):void 27 | { 28 | _topRightColor = value; 29 | setVertexColor(1, value); 30 | } 31 | public function set bottomLeftColor(value:uint):void 32 | { 33 | _bottomLeftColor = value; 34 | setVertexColor(2, value); 35 | } 36 | public function set bottomRightColor(value:uint):void 37 | { 38 | _bottomRightColor = value; 39 | setVertexColor(3, value); 40 | } 41 | public function get topLeftColor():uint 42 | { 43 | return _topLeftColor; 44 | } 45 | public function get topRightColor():uint 46 | { 47 | return _topRightColor; 48 | } 49 | public function get bottomLeftColor():uint 50 | { 51 | return _bottomLeftColor; 52 | } 53 | public function get bottomRightColor():uint 54 | { 55 | return _bottomRightColor; 56 | } 57 | } 58 | } --------------------------------------------------------------------------------