├── .gitignore ├── README.md ├── Universal.hx ├── block-icons ├── actor-anon.png ├── actor-drawing.png ├── actor.png ├── arrow-0.png ├── arrow-090.png ├── arrow-180.png ├── arrow-270.png ├── arrow-move.png ├── arrow-stop-090.png ├── arrow-stop-180.png ├── arrow-stop-270.png ├── arrow-stop.png ├── break.png ├── camera.png ├── cancel.png ├── clock-future.png ├── clock.png ├── collide.png ├── color.png ├── console.png ├── continue.png ├── controller.png ├── create.png ├── cursor.png ├── desktop.png ├── draw.png ├── events │ ├── actor.png │ ├── advanced.png │ ├── att-any.png │ ├── att-bool.png │ ├── att-number.png │ ├── attributes.png │ ├── basic.png │ ├── collision.png │ ├── controller.png │ ├── created.png │ ├── do-later.png │ ├── group.png │ ├── keyboard.png │ ├── money.png │ ├── mouse-actor.png │ ├── mouse-region.png │ ├── mouse.png │ ├── pause.png │ ├── periodic.png │ ├── region.png │ ├── screen-fullscreen.png │ ├── screen-gamescale.png │ ├── screen-scene.png │ ├── screen-screensize.png │ ├── screen.png │ ├── sound-channel.png │ ├── sound-sound.png │ ├── sound.png │ ├── swipe.png │ ├── tag-arrow.png │ ├── tag-label-purple.png │ ├── target.png │ ├── tilt.png │ ├── time.png │ ├── touch.png │ ├── type.png │ ├── when-creating.png │ ├── when-drawing.png │ └── when-updating.png ├── flash.png ├── font.png ├── keyboard.png ├── mobile.png ├── mochi.png ├── money.png ├── mouse-select-right.png ├── mouse-select.png ├── mouse-wheel.png ├── mouse.png ├── picker │ ├── attribute.png │ ├── collision.png │ ├── favorite.png │ └── game.png ├── question.png ├── rot-ccw.png ├── rot-cw.png ├── save.png ├── scene.png ├── score.png ├── screen-fullscreen.png ├── screen-gamescale.png ├── screen-screensize.png ├── screen.png ├── small-down.png ├── small-up.png ├── sound.png ├── step.png ├── stop.png ├── swipe.png ├── target.png ├── tilt.png ├── touch.png ├── vars.png ├── volume-down.png ├── volume-mute.png ├── volume-up.png ├── volume.png └── web.png ├── blocks.xml ├── com └── stencyl │ ├── Config.hx │ ├── Data.hx │ ├── Engine.hx │ ├── Extension.hx │ ├── Input.hx │ ├── Key.hx │ ├── behavior │ ├── ActorScript.hx │ ├── Attribute.hx │ ├── Behavior.hx │ ├── BehaviorInstance.hx │ ├── BehaviorManager.hx │ ├── ReflectionHelper.hx │ ├── SceneScript.hx │ ├── Script.hx │ └── TimedTask.hx │ ├── event │ ├── Event.hx │ ├── EventDispatcher.hx │ └── EventMap.hx │ ├── graphics │ ├── AbstractAnimation.hx │ ├── BitmapAnimation.hx │ ├── BitmapDataTileSourcePatch.hx │ ├── BitmapWrapper.hx │ ├── BlendModes.hx │ ├── ColorMatrixShader.hx │ ├── DynamicTileset.hx │ ├── EngineScaleUpdateListener.hx │ ├── G.hx │ ├── GLUtil.hx │ ├── Scale.hx │ ├── ScaleMode.hx │ ├── SheetAnimation.hx │ ├── TextureAtlas.hx │ ├── TileSource.hx │ ├── TilesetUtils.hx │ ├── fonts │ │ ├── BitmapFont.hx │ │ └── FontSymbol.hx │ ├── shaders │ │ ├── BasicShader.hx │ │ ├── BloomShader.hx │ │ ├── BlurShader.hx │ │ ├── CSBShader.hx │ │ ├── ExternalShader.hx │ │ ├── GrainShader.hx │ │ ├── GrayscaleShader.hx │ │ ├── HueShader.hx │ │ ├── InlineShader.hx │ │ ├── InvertShader.hx │ │ ├── PostProcess.hx │ │ ├── ScanlineShader.hx │ │ ├── SepiaShader.hx │ │ ├── Shader.hx │ │ ├── SharpenShader.hx │ │ └── TintShader.hx │ └── transitions │ │ ├── BlindsTransition.hx │ │ ├── BubblesTransition.hx │ │ ├── CircleTransition.hx │ │ ├── CrossfadeTransition.hx │ │ ├── FadeInTransition.hx │ │ ├── FadeOutTransition.hx │ │ ├── PixelizeTransition.hx │ │ ├── RectangleTransition.hx │ │ ├── SlideTransition.hx │ │ └── Transition.hx │ ├── io │ ├── AbstractReader.hx │ ├── ActorTypeReader.hx │ ├── AttributeValues.hx │ ├── BackgroundReader.hx │ ├── BehaviorReader.hx │ ├── FontReader.hx │ ├── ShapeReader.hx │ ├── SoundReader.hx │ ├── SpriteReader.hx │ ├── TilesetReader.hx │ └── mbs │ │ ├── MbsBackground.hx │ │ ├── MbsBlank.hx │ │ ├── MbsCustomBlock.hx │ │ ├── MbsFont.hx │ │ ├── MbsMusic.hx │ │ ├── MbsResource.hx │ │ ├── Typedefs.hx │ │ ├── actortype │ │ ├── MbsActorType.hx │ │ ├── MbsAnimShape.hx │ │ ├── MbsAnimation.hx │ │ └── MbsSprite.hx │ │ ├── game │ │ ├── MbsAtlas.hx │ │ ├── MbsCollisionGroup.hx │ │ ├── MbsCollisionPair.hx │ │ ├── MbsCollisionShape.hx │ │ ├── MbsGame.hx │ │ └── autotile │ │ │ ├── MbsAutotileFormat.hx │ │ │ └── MbsCorners.hx │ │ ├── scene │ │ ├── MbsActorInstance.hx │ │ ├── MbsScene.hx │ │ ├── MbsSceneHeader.hx │ │ ├── MbsTile.hx │ │ ├── MbsTileset.hx │ │ ├── layers │ │ │ ├── MbsColorBackground.hx │ │ │ ├── MbsGradientBackground.hx │ │ │ ├── MbsImageBackground.hx │ │ │ ├── MbsInteractiveLayer.hx │ │ │ └── MbsLayer.hx │ │ └── physics │ │ │ ├── MbsHingeJoint.hx │ │ │ ├── MbsJoint.hx │ │ │ ├── MbsRegion.hx │ │ │ ├── MbsSlidingJoint.hx │ │ │ ├── MbsStickJoint.hx │ │ │ └── MbsTerrainRegion.hx │ │ ├── shape │ │ ├── MbsCircle.hx │ │ ├── MbsPoint.hx │ │ ├── MbsPolyRegion.hx │ │ ├── MbsPolygon.hx │ │ ├── MbsShape.hx │ │ └── MbsWireframe.hx │ │ └── snippet │ │ ├── MbsAttribute.hx │ │ ├── MbsAttributeDef.hx │ │ ├── MbsBlock.hx │ │ ├── MbsEvent.hx │ │ ├── MbsMapElement.hx │ │ ├── MbsSnippet.hx │ │ └── MbsSnippetDef.hx │ ├── loader │ ├── CustomSwfPreloader.hx │ ├── PreloaderConfig.hx │ ├── SiteLock.hx │ ├── SplashBox.hx │ ├── StencylPreloader.hx │ └── SwfPreloaderConfig.hx │ ├── models │ ├── Actor.hx │ ├── Atlas.hx │ ├── Background.hx │ ├── CollisionGroupDef.hx │ ├── Font.hx │ ├── GameModel.hx │ ├── GroupDef.hx │ ├── Joystick.hx │ ├── PhysicsMode.hx │ ├── Region.hx │ ├── Resource.hx │ ├── Scene.hx │ ├── Sound.hx │ ├── SoundChannel.hx │ ├── Terrain.hx │ ├── actor │ │ ├── ActorTweenProperties.hx │ │ ├── ActorType.hx │ │ ├── AngleHolder.hx │ │ ├── Animation.hx │ │ ├── Collision.hx │ │ ├── CollisionPoint.hx │ │ ├── Group.hx │ │ └── Sprite.hx │ ├── background │ │ ├── ColorBackground.hx │ │ ├── GradientBackground.hx │ │ ├── ImageBackground.hx │ │ └── ScrollingBackground.hx │ ├── collision │ │ ├── CollisionInfo.hx │ │ ├── Grid.hx │ │ ├── Hitbox.hx │ │ ├── Mask.hx │ │ ├── Masklist.hx │ │ └── Pixelmask.hx │ └── scene │ │ ├── ActorInstance.hx │ │ ├── ActorLayer.hx │ │ ├── Autotile.hx │ │ ├── AutotileFormat.hx │ │ ├── DeferredActor.hx │ │ ├── DrawingLayer.hx │ │ ├── Layer.hx │ │ ├── RegionDef.hx │ │ ├── ScrollingBitmap.hx │ │ ├── TerrainDef.hx │ │ ├── Tile.hx │ │ ├── TileLayer.hx │ │ ├── Tileset.hx │ │ ├── Wireframe.hx │ │ └── layers │ │ ├── BackgroundLayer.hx │ │ └── RegularLayer.hx │ └── utils │ ├── ARGB.hx │ ├── Assets.hx │ ├── ColorMatrix.hx │ ├── ConfigUtil.hx │ ├── HaxeDefines.hx │ ├── HscriptRunner.hx │ ├── LazyIntMap.hx │ ├── LazyMap.hx │ ├── LazyStringMap.hx │ ├── Log.hx │ ├── Mathematics.hx │ ├── PolyDecompBayazit.hx │ ├── RGB.hx │ ├── ToolsetInterface.hx │ ├── Utils.hx │ └── motion │ ├── Easing.hx │ ├── EasingConstants.hx │ ├── EasingFunction.hx │ ├── EasingFunctions.hx │ ├── TweenFloat.hx │ ├── TweenFloat2.hx │ ├── TweenManager.hx │ ├── TweenObject.hx │ └── TweenTimer.hx ├── docs ├── .gitignore ├── ImportAll.hx ├── compile-rtti.hxml ├── generate-api-docs.bat ├── generate-api-docs.sh ├── run-dox.hxml └── scripts │ └── MyScripts.hx ├── events.xml ├── haxelib.json ├── include.xml ├── info.txt ├── lang ├── de │ ├── behavior-blockhelp.lang │ └── behavior-blocks.lang ├── el │ ├── behavior-blockhelp.lang │ └── behavior-blocks.lang ├── en │ ├── behavior-blockhelp.lang │ ├── behavior-blocks.lang │ └── behavior-events.lang ├── es │ ├── behavior-blockhelp.lang │ └── behavior-blocks.lang ├── fi │ ├── behavior-blockhelp.lang │ └── behavior-blocks.lang ├── fr │ ├── behavior-blockhelp.lang │ ├── behavior-blocks.lang │ └── behavior-events.lang ├── it │ ├── behavior-blockhelp.lang │ ├── behavior-blocks.lang │ └── behavior-events.lang ├── nl │ ├── behavior-blockhelp.lang │ └── behavior-blocks.lang ├── pl │ ├── behavior-blockhelp.lang │ └── behavior-blocks.lang ├── pt │ ├── behavior-blockhelp.lang │ └── behavior-blocks.lang ├── ru │ ├── behavior-blockhelp.lang │ └── behavior-blocks.lang ├── zh │ ├── behavior-blockhelp.lang │ └── behavior-blocks.lang └── zh_CN │ ├── behavior-blockhelp.lang │ └── behavior-blocks.lang ├── native ├── block-icons │ ├── keyboard.png │ └── mobile.png ├── blocks.xml ├── dependencies │ └── native │ │ └── src │ │ └── com │ │ └── androidnative │ │ └── Native.java ├── haxelib.json ├── icon.png ├── include.xml ├── info.txt ├── lang │ ├── el │ │ └── com.stencyl.native.lang │ ├── en │ │ └── com.stencyl.native.lang │ ├── es │ │ └── com.stencyl.native.lang │ ├── fr │ │ └── com.stencyl.native.lang │ ├── it │ │ └── com.stencyl.native.lang │ ├── pt │ │ └── com.stencyl.native.lang │ └── ru │ │ └── com.stencyl.native.lang ├── project │ ├── Build.xml │ ├── common │ │ └── ExternalInterface.cpp │ ├── include │ │ └── Native.h │ └── iphone │ │ └── Native.mm ├── services.xml ├── src │ └── com │ │ └── stencyl │ │ └── native │ │ └── Native.hx └── stencyl-addons.xml ├── palette.xml ├── scripts └── MyAssets.hx ├── src-override ├── js │ └── _std │ │ └── haxe │ │ └── NativeStackTrace.hx └── lime │ └── utils │ └── Log.hx ├── templates └── haxe │ └── ApplicationMain.hx └── tools └── run ├── RunMain.hx └── compile.hxml /.gitignore: -------------------------------------------------------------------------------- 1 | run.n -------------------------------------------------------------------------------- /block-icons/actor-anon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/actor-anon.png -------------------------------------------------------------------------------- /block-icons/actor-drawing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/actor-drawing.png -------------------------------------------------------------------------------- /block-icons/actor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/actor.png -------------------------------------------------------------------------------- /block-icons/arrow-0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/arrow-0.png -------------------------------------------------------------------------------- /block-icons/arrow-090.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/arrow-090.png -------------------------------------------------------------------------------- /block-icons/arrow-180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/arrow-180.png -------------------------------------------------------------------------------- /block-icons/arrow-270.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/arrow-270.png -------------------------------------------------------------------------------- /block-icons/arrow-move.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/arrow-move.png -------------------------------------------------------------------------------- /block-icons/arrow-stop-090.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/arrow-stop-090.png -------------------------------------------------------------------------------- /block-icons/arrow-stop-180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/arrow-stop-180.png -------------------------------------------------------------------------------- /block-icons/arrow-stop-270.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/arrow-stop-270.png -------------------------------------------------------------------------------- /block-icons/arrow-stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/arrow-stop.png -------------------------------------------------------------------------------- /block-icons/break.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/break.png -------------------------------------------------------------------------------- /block-icons/camera.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/camera.png -------------------------------------------------------------------------------- /block-icons/cancel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/cancel.png -------------------------------------------------------------------------------- /block-icons/clock-future.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/clock-future.png -------------------------------------------------------------------------------- /block-icons/clock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/clock.png -------------------------------------------------------------------------------- /block-icons/collide.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/collide.png -------------------------------------------------------------------------------- /block-icons/color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/color.png -------------------------------------------------------------------------------- /block-icons/console.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/console.png -------------------------------------------------------------------------------- /block-icons/continue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/continue.png -------------------------------------------------------------------------------- /block-icons/controller.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/controller.png -------------------------------------------------------------------------------- /block-icons/create.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/create.png -------------------------------------------------------------------------------- /block-icons/cursor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/cursor.png -------------------------------------------------------------------------------- /block-icons/desktop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/desktop.png -------------------------------------------------------------------------------- /block-icons/draw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/draw.png -------------------------------------------------------------------------------- /block-icons/events/actor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/actor.png -------------------------------------------------------------------------------- /block-icons/events/advanced.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/advanced.png -------------------------------------------------------------------------------- /block-icons/events/att-any.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/att-any.png -------------------------------------------------------------------------------- /block-icons/events/att-bool.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/att-bool.png -------------------------------------------------------------------------------- /block-icons/events/att-number.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/att-number.png -------------------------------------------------------------------------------- /block-icons/events/attributes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/attributes.png -------------------------------------------------------------------------------- /block-icons/events/basic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/basic.png -------------------------------------------------------------------------------- /block-icons/events/collision.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/collision.png -------------------------------------------------------------------------------- /block-icons/events/controller.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/controller.png -------------------------------------------------------------------------------- /block-icons/events/created.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/created.png -------------------------------------------------------------------------------- /block-icons/events/do-later.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/do-later.png -------------------------------------------------------------------------------- /block-icons/events/group.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/group.png -------------------------------------------------------------------------------- /block-icons/events/keyboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/keyboard.png -------------------------------------------------------------------------------- /block-icons/events/money.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/money.png -------------------------------------------------------------------------------- /block-icons/events/mouse-actor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/mouse-actor.png -------------------------------------------------------------------------------- /block-icons/events/mouse-region.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/mouse-region.png -------------------------------------------------------------------------------- /block-icons/events/mouse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/mouse.png -------------------------------------------------------------------------------- /block-icons/events/pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/pause.png -------------------------------------------------------------------------------- /block-icons/events/periodic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/periodic.png -------------------------------------------------------------------------------- /block-icons/events/region.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/region.png -------------------------------------------------------------------------------- /block-icons/events/screen-fullscreen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/screen-fullscreen.png -------------------------------------------------------------------------------- /block-icons/events/screen-gamescale.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/screen-gamescale.png -------------------------------------------------------------------------------- /block-icons/events/screen-scene.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/screen-scene.png -------------------------------------------------------------------------------- /block-icons/events/screen-screensize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/screen-screensize.png -------------------------------------------------------------------------------- /block-icons/events/screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/screen.png -------------------------------------------------------------------------------- /block-icons/events/sound-channel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/sound-channel.png -------------------------------------------------------------------------------- /block-icons/events/sound-sound.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/sound-sound.png -------------------------------------------------------------------------------- /block-icons/events/sound.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/sound.png -------------------------------------------------------------------------------- /block-icons/events/swipe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/swipe.png -------------------------------------------------------------------------------- /block-icons/events/tag-arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/tag-arrow.png -------------------------------------------------------------------------------- /block-icons/events/tag-label-purple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/tag-label-purple.png -------------------------------------------------------------------------------- /block-icons/events/target.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/target.png -------------------------------------------------------------------------------- /block-icons/events/tilt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/tilt.png -------------------------------------------------------------------------------- /block-icons/events/time.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/time.png -------------------------------------------------------------------------------- /block-icons/events/touch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/touch.png -------------------------------------------------------------------------------- /block-icons/events/type.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/type.png -------------------------------------------------------------------------------- /block-icons/events/when-creating.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/when-creating.png -------------------------------------------------------------------------------- /block-icons/events/when-drawing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/when-drawing.png -------------------------------------------------------------------------------- /block-icons/events/when-updating.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/events/when-updating.png -------------------------------------------------------------------------------- /block-icons/flash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/flash.png -------------------------------------------------------------------------------- /block-icons/font.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/font.png -------------------------------------------------------------------------------- /block-icons/keyboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/keyboard.png -------------------------------------------------------------------------------- /block-icons/mobile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/mobile.png -------------------------------------------------------------------------------- /block-icons/mochi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/mochi.png -------------------------------------------------------------------------------- /block-icons/money.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/money.png -------------------------------------------------------------------------------- /block-icons/mouse-select-right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/mouse-select-right.png -------------------------------------------------------------------------------- /block-icons/mouse-select.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/mouse-select.png -------------------------------------------------------------------------------- /block-icons/mouse-wheel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/mouse-wheel.png -------------------------------------------------------------------------------- /block-icons/mouse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/mouse.png -------------------------------------------------------------------------------- /block-icons/picker/attribute.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/picker/attribute.png -------------------------------------------------------------------------------- /block-icons/picker/collision.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/picker/collision.png -------------------------------------------------------------------------------- /block-icons/picker/favorite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/picker/favorite.png -------------------------------------------------------------------------------- /block-icons/picker/game.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/picker/game.png -------------------------------------------------------------------------------- /block-icons/question.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/question.png -------------------------------------------------------------------------------- /block-icons/rot-ccw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/rot-ccw.png -------------------------------------------------------------------------------- /block-icons/rot-cw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/rot-cw.png -------------------------------------------------------------------------------- /block-icons/save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/save.png -------------------------------------------------------------------------------- /block-icons/scene.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/scene.png -------------------------------------------------------------------------------- /block-icons/score.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/score.png -------------------------------------------------------------------------------- /block-icons/screen-fullscreen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/screen-fullscreen.png -------------------------------------------------------------------------------- /block-icons/screen-gamescale.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/screen-gamescale.png -------------------------------------------------------------------------------- /block-icons/screen-screensize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/screen-screensize.png -------------------------------------------------------------------------------- /block-icons/screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/screen.png -------------------------------------------------------------------------------- /block-icons/small-down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/small-down.png -------------------------------------------------------------------------------- /block-icons/small-up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/small-up.png -------------------------------------------------------------------------------- /block-icons/sound.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/sound.png -------------------------------------------------------------------------------- /block-icons/step.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/step.png -------------------------------------------------------------------------------- /block-icons/stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/stop.png -------------------------------------------------------------------------------- /block-icons/swipe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/swipe.png -------------------------------------------------------------------------------- /block-icons/target.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/target.png -------------------------------------------------------------------------------- /block-icons/tilt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/tilt.png -------------------------------------------------------------------------------- /block-icons/touch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/touch.png -------------------------------------------------------------------------------- /block-icons/vars.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/vars.png -------------------------------------------------------------------------------- /block-icons/volume-down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/volume-down.png -------------------------------------------------------------------------------- /block-icons/volume-mute.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/volume-mute.png -------------------------------------------------------------------------------- /block-icons/volume-up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/volume-up.png -------------------------------------------------------------------------------- /block-icons/volume.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/volume.png -------------------------------------------------------------------------------- /block-icons/web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stencyl/stencyl-engine/c2af51aee6d6f28f0d792684b7f3e8bb4ed8a24a/block-icons/web.png -------------------------------------------------------------------------------- /com/stencyl/Extension.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl; 2 | 3 | import com.stencyl.models.GameModel; 4 | import com.stencyl.models.Scene; 5 | 6 | class Extension 7 | { 8 | /** 9 | * Extensions are constructed before the preloader is shown and assets are loaded. 10 | */ 11 | public function new() 12 | { 13 | } 14 | 15 | /** 16 | * Called when the game is started, before the first scene is loaded. 17 | */ 18 | public function initialize() 19 | { 20 | 21 | } 22 | 23 | /** 24 | * Called when a new scene is being loaded. 25 | * This is an ideal place to prepare event 26 | * queues for use. 27 | */ 28 | public function loadScene(scene:Scene) 29 | { 30 | 31 | } 32 | 33 | /** 34 | * Called when a scene is being left. 35 | * Dispose of scene-specific data. 36 | */ 37 | public function cleanupScene() 38 | { 39 | 40 | } 41 | 42 | /** 43 | * Called before the whenUpdated event is dispatched. 44 | */ 45 | public function preSceneUpdate() 46 | { 47 | 48 | } 49 | 50 | /** 51 | * Called when a game is being reloaded. 52 | * Reset static variables to their initial state if needed. 53 | */ 54 | public function reloadGame() 55 | { 56 | 57 | } 58 | } -------------------------------------------------------------------------------- /com/stencyl/behavior/ActorScript.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.behavior; 2 | 3 | import com.stencyl.models.Actor; 4 | 5 | class ActorScript extends Script 6 | { 7 | public var actor:Actor; 8 | 9 | public function new(actor:Actor) 10 | { 11 | super(); 12 | 13 | this.actor = actor; 14 | } 15 | 16 | //*----------------------------------------------- 17 | //* Messaging 18 | //*----------------------------------------------- 19 | 20 | public function getValue(behaviorName:String, attributeName:String):Dynamic 21 | { 22 | return actor.getValue(behaviorName, attributeName); 23 | } 24 | 25 | public function setValue(behaviorName:String, attributeName:String, value:Dynamic) 26 | { 27 | actor.setValue(behaviorName, attributeName, value); 28 | } 29 | 30 | public function shout(msg:String, args:Array):Dynamic 31 | { 32 | return actor.shout(msg, args); 33 | } 34 | 35 | override public function disableThisBehavior() 36 | { 37 | actor.disableBehavior(wrapper.name); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /com/stencyl/behavior/BehaviorInstance.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.behavior; 2 | 3 | class BehaviorInstance 4 | { 5 | public var behaviorID:Int; 6 | public var values:Map; 7 | public var enabled:Bool; 8 | 9 | public function new(behaviorID:Int, values:Map) 10 | { 11 | this.behaviorID = behaviorID; 12 | this.values = values; 13 | this.enabled = true; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /com/stencyl/behavior/ReflectionHelper.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.behavior; 2 | 3 | import com.stencyl.utils.Log; 4 | import com.stencyl.utils.Utils; 5 | 6 | import openfl.display.Graphics; 7 | import haxe.ds.StringMap; 8 | import haxe.CallStack; 9 | import haxe.Constraints.IMap; 10 | 11 | class ReflectionHelper 12 | { 13 | //classname -> (field name set) 14 | public static var fieldMaps:Map> = new Map>(); 15 | 16 | public static function getFieldMap(classname:String):Map 17 | { 18 | var fieldMap = fieldMaps.get(classname); 19 | if(fieldMap == null) 20 | { 21 | try 22 | { 23 | var cls = Type.resolveClass(classname); 24 | var fieldList = Type.getInstanceFields(cls); 25 | fieldMap = [for(fieldName in fieldList) fieldName => true]; 26 | fieldMaps.set(classname, fieldMap); 27 | } 28 | 29 | catch(e: #if (haxe_ver >= 4.1) haxe.Exception #else String #end ) 30 | { 31 | Log.fullError("Could not load: " + classname, e); 32 | } 33 | } 34 | return fieldMap; 35 | } 36 | 37 | public static function hasField(classname:String, fieldname:String):Bool 38 | { 39 | var fieldMap = getFieldMap(classname); 40 | if(fieldMap == null) return false; 41 | return fieldMap.exists(fieldname); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /com/stencyl/behavior/SceneScript.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.behavior; 2 | 3 | class SceneScript extends Script 4 | { 5 | public function new() 6 | { 7 | super(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /com/stencyl/behavior/TimedTask.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.behavior; 2 | 3 | import com.stencyl.models.Actor; 4 | 5 | class TimedTask 6 | { 7 | public var toExecute:TimedTask->Void; 8 | public var interval:Int; 9 | public var repeats:Bool; 10 | public var actor:Actor; 11 | 12 | private var timer:Int; 13 | 14 | public var done:Bool; 15 | 16 | //Used as an efficient way to tell different "incarnations" of recycled actors apart. 17 | public var actorCreateTime:Float; 18 | 19 | public function new(toExecute:TimedTask->Void, interval:Int, repeats:Bool, actor:Actor = null) 20 | { 21 | this.toExecute = toExecute; 22 | this.interval = interval; 23 | this.repeats = repeats; 24 | this.actor = actor; 25 | 26 | done = false; 27 | 28 | timer = interval; 29 | } 30 | 31 | public function update(timeElapsed:Int) 32 | { 33 | if(actor != null && !actor.isAlive()) 34 | { 35 | done = true; 36 | return; 37 | } 38 | 39 | if((actor == null && Engine.engine.isPaused()) || (actor != null && actor.isPaused())) 40 | { 41 | return; 42 | } 43 | 44 | timer -= timeElapsed; 45 | 46 | if(timer <= 0) 47 | { 48 | toExecute(this); 49 | done = !repeats; 50 | 51 | if(repeats) 52 | { 53 | timer += interval; 54 | } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /com/stencyl/event/Event.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.event; 2 | 3 | class Event 4 | { 5 | public var listeners:Array; 6 | public var length:Int; 7 | private var _dispatchIndex:Int = -1; 8 | #if debug_event_dispatch 9 | public var posInfos:Array; 10 | #end 11 | 12 | /** 13 | Creates a new Event instance 14 | **/ 15 | public function new() 16 | { 17 | listeners = new Array(); 18 | length = 0; 19 | 20 | #if debug_event_dispatch 21 | posInfos = new Array(); 22 | #end 23 | } 24 | 25 | /** 26 | Adds a new event listener 27 | @param listener A callback that matches the signature of the event 28 | **/ 29 | public function add(listener:T #if debug_event_dispatch , posInfo:haxe.PosInfos #end):Void 30 | { 31 | listeners.push(listener); 32 | ++length; 33 | 34 | #if debug_event_dispatch 35 | posInfos.push(posInfo); 36 | #end 37 | } 38 | 39 | /** 40 | Checks whether a callback is a listener to this event 41 | @param listener A callback that matches the signature of the event 42 | @return Whether the callback is a listener 43 | **/ 44 | public function has(listener:T):Bool 45 | { 46 | for (l in listeners) 47 | { 48 | if (Reflect.compareMethods(l, listener)) return true; 49 | } 50 | 51 | return false; 52 | } 53 | 54 | /** 55 | Removes an event listener 56 | @param listener A callback that matches the signature of the event 57 | **/ 58 | public function remove(listener:T):Void 59 | { 60 | var i = listeners.length; 61 | 62 | while (--i >= 0) 63 | { 64 | if (Reflect.compareMethods(listeners[i], listener)) 65 | { 66 | listeners.splice(i, 1); 67 | --length; 68 | if(_dispatchIndex >= i) 69 | --_dispatchIndex; 70 | 71 | #if debug_event_dispatch 72 | posInfos.splice(i, 1); 73 | #end 74 | } 75 | } 76 | } 77 | 78 | /** 79 | Removes all event listeners 80 | **/ 81 | public function removeAll():Void 82 | { 83 | listeners.splice(0, length); 84 | length = 0; 85 | _dispatchIndex = 0; 86 | 87 | #if debug_event_dispatch 88 | posInfos.splice(0, posInfos.length); 89 | #end 90 | } 91 | } -------------------------------------------------------------------------------- /com/stencyl/event/EventDispatcher.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.event; 2 | 3 | import haxe.macro.Context; 4 | import haxe.macro.Expr; 5 | import haxe.macro.PositionTools; 6 | 7 | class EventDispatcher 8 | { 9 | /** 10 | Dispatches a new event callback to all listeners. The signature for the 11 | `dispatch` method depends upon the type of the `Event`. For example, an 12 | `Event` of type `Int->Int->Void` will create a `dispatch` method that 13 | takes two `Int` arguments, like `dispatch (1, 2);` 14 | **/ 15 | macro public static function dispatch(event:ExprOf>, args:Array):Expr 16 | { 17 | //var posInfos = PositionTools.toLocation(Context.currentPos()); 18 | //var posInfos = Context.getPosInfos(Context.currentPos()); 19 | 20 | @:pos(Context.currentPos()) 21 | return macro 22 | { 23 | @:privateAccess 24 | if($event.length > 0) 25 | { 26 | $event._dispatchIndex = 0; 27 | while($event._dispatchIndex < $event.length) 28 | { 29 | #if debug_event_dispatch 30 | var posinfo = $event.posInfos[$event._dispatchIndex]; 31 | com.stencyl.utils.Log.verbose("Call event from: " + posinfo.fileName + ":" + posinfo.lineNumber); 32 | #end 33 | try 34 | { 35 | $event.listeners[$event._dispatchIndex]($a{args}); 36 | } 37 | catch(e: #if (haxe_ver >= 4.1) haxe.Exception #else Dynamic #end ) 38 | { 39 | com.stencyl.utils.Log.fullError(e.message, e); 40 | } 41 | ++$event._dispatchIndex; 42 | } 43 | } 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /com/stencyl/event/EventMap.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.event; 2 | 3 | @:generic @:remove 4 | class EventMap 5 | { 6 | public var keys:Array; 7 | public var map:Map; 8 | 9 | public function new() 10 | { 11 | keys = []; 12 | map = new Map(); 13 | } 14 | 15 | public inline function hasEvents():Bool 16 | { 17 | return keys.length > 0; 18 | } 19 | 20 | public function getOrCreateEvent(key:K):T 21 | { 22 | var event = map.get(key); 23 | 24 | if(event == null) 25 | { 26 | event = cast new Event(); 27 | map.set(key, event); 28 | keys.push(key); 29 | } 30 | 31 | return event; 32 | } 33 | 34 | public inline function getEvent(key:K):T 35 | { 36 | return map.get(key); 37 | } 38 | } -------------------------------------------------------------------------------- /com/stencyl/graphics/AbstractAnimation.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.graphics; 2 | 3 | import openfl.display.BitmapData; 4 | 5 | interface AbstractAnimation 6 | { 7 | public function update(elapsedTime:Float):Void; 8 | public function getCurrentFrame():Int; 9 | public function getNumFrames():Int; 10 | public function setFrame(frame:Int):Void; 11 | public function isFinished():Bool; 12 | public function activate():Void; 13 | public function reset():Void; 14 | public function draw(g:G, x:Float, y:Float, angle:Float, alpha:Float):Void; 15 | public function getFrameDurations():Array; 16 | public function setFrameDurations(time:Int):Void; 17 | public function setFrameDuration(frame:Int, time:Int):Void; 18 | public function getCurrentImage():BitmapData; 19 | } 20 | -------------------------------------------------------------------------------- /com/stencyl/graphics/BitmapDataTileSourcePatch.hx: -------------------------------------------------------------------------------- 1 | #if macro 2 | 3 | package com.stencyl.graphics; 4 | 5 | import haxe.macro.Context; 6 | import haxe.macro.Expr; 7 | 8 | class BitmapDataTileSourcePatch 9 | { 10 | //add field to BitmapData: 11 | // private var __tileSource:com.stencyl.graphics.TileSource 12 | 13 | macro public static function patch():Array 14 | { 15 | var fields = Context.getBuildFields(); 16 | var newField = { 17 | name: "__tileSource", 18 | doc: null, 19 | meta: [], 20 | access: [APrivate], 21 | kind: FVar(macro:com.stencyl.graphics.TileSource), 22 | pos: Context.currentPos() 23 | }; 24 | fields.push(newField); 25 | return fields; 26 | } 27 | } 28 | 29 | #end -------------------------------------------------------------------------------- /com/stencyl/graphics/BlendModes.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.graphics; 2 | 3 | import openfl.display.BlendMode; 4 | 5 | class BlendModes 6 | { 7 | private static var stringBlendMap:Map = 8 | { 9 | var m = new Map(); 10 | m.set("add", BlendMode.ADD); 11 | m.set("alpha", BlendMode.ALPHA); 12 | m.set("darken", BlendMode.DARKEN); 13 | m.set("difference", BlendMode.DIFFERENCE); 14 | m.set("erase", BlendMode.ERASE); 15 | m.set("hardlight", BlendMode.HARDLIGHT); 16 | m.set("invert", BlendMode.INVERT); 17 | m.set("lighten", BlendMode.LIGHTEN); 18 | m.set("multiply", BlendMode.MULTIPLY); 19 | m.set("normal", BlendMode.NORMAL); 20 | m.set("overlay", BlendMode.OVERLAY); 21 | m.set("screen", BlendMode.SCREEN); 22 | m.set("subtract", BlendMode.SUBTRACT); 23 | m; 24 | } 25 | 26 | public static function get(blendName:String):BlendMode 27 | { 28 | return stringBlendMap.get(blendName); 29 | } 30 | } -------------------------------------------------------------------------------- /com/stencyl/graphics/ColorMatrixShader.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.graphics; 2 | 3 | import openfl.display.Shader; 4 | 5 | #if !flash 6 | 7 | class ColorMatrixShader extends Shader 8 | { 9 | @:glFragmentSource( 10 | 11 | "varying float openfl_Alphav; 12 | varying vec2 openfl_TextureCoordv; 13 | uniform sampler2D openfl_Texture; 14 | 15 | uniform mat4 uMultipliers; 16 | uniform vec4 uOffsets; 17 | 18 | void main(void) 19 | { 20 | vec4 color = texture2D(openfl_Texture, openfl_TextureCoordv); 21 | 22 | if(color.a == 0.0) 23 | { 24 | gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); 25 | } 26 | else 27 | { 28 | color = vec4(color.rgb / color.a, color.a); 29 | color = uOffsets + color * uMultipliers; 30 | 31 | gl_FragColor = vec4(color.rgb * color.a * openfl_Alphav, color.a * openfl_Alphav); 32 | } 33 | }" 34 | 35 | ) 36 | 37 | @:glVertexSource( 38 | 39 | "attribute float openfl_Alpha; 40 | attribute vec4 openfl_ColorMultiplier; 41 | attribute vec4 openfl_ColorOffset; 42 | attribute vec4 openfl_Position; 43 | attribute vec2 openfl_TextureCoord; 44 | varying float openfl_Alphav; 45 | varying vec2 openfl_TextureCoordv; 46 | 47 | uniform mat4 openfl_Matrix; 48 | uniform bool openfl_HasColorTransform; 49 | 50 | void main(void) { 51 | 52 | openfl_Alphav = openfl_Alpha; 53 | openfl_TextureCoordv = openfl_TextureCoord; 54 | 55 | gl_Position = openfl_Matrix * openfl_Position; 56 | 57 | }" 58 | 59 | ) 60 | 61 | public function new() 62 | { 63 | super(); 64 | } 65 | 66 | public function init(matrix:Array = null):Void 67 | { 68 | if(matrix == null || uMultipliers.value == null) 69 | { 70 | uMultipliers.value = [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]; 71 | uOffsets.value = [ 0, 0, 0, 0 ]; 72 | } 73 | 74 | if(matrix == null) 75 | { 76 | return; 77 | } 78 | 79 | var multipliers = uMultipliers.value; 80 | var offsets = uOffsets.value; 81 | 82 | multipliers[0] = matrix[0]; 83 | multipliers[1] = matrix[1]; 84 | multipliers[2] = matrix[2]; 85 | multipliers[3] = matrix[3]; 86 | multipliers[4] = matrix[5]; 87 | multipliers[5] = matrix[6]; 88 | multipliers[6] = matrix[7]; 89 | multipliers[7] = matrix[8]; 90 | multipliers[8] = matrix[10]; 91 | multipliers[9] = matrix[11]; 92 | multipliers[10] = matrix[12]; 93 | multipliers[11] = matrix[13]; 94 | multipliers[12] = matrix[15]; 95 | multipliers[13] = matrix[16]; 96 | multipliers[14] = matrix[17]; 97 | multipliers[15] = matrix[18]; 98 | 99 | offsets[0] = matrix[4] / 255.0; 100 | offsets[1] = matrix[9] / 255.0; 101 | offsets[2] = matrix[14] / 255.0; 102 | offsets[3] = matrix[19] / 255.0; 103 | } 104 | } 105 | #end 106 | -------------------------------------------------------------------------------- /com/stencyl/graphics/EngineScaleUpdateListener.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.graphics; 2 | 3 | interface EngineScaleUpdateListener 4 | { 5 | function updateScale():Void; 6 | } -------------------------------------------------------------------------------- /com/stencyl/graphics/Scale.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.graphics; 2 | 3 | class Scale 4 | { 5 | public static var _1X = new Scale(1.0); 6 | public static var _1_5X = new Scale(1.5); 7 | public static var _2X = new Scale(2.0); 8 | public static var _3X = new Scale(3.0); 9 | public static var _4X = new Scale(4.0); 10 | 11 | public var value(default, null):Float; 12 | 13 | public function new(value:Float) 14 | { 15 | this.value = value; 16 | } 17 | 18 | public static function fromString (value:String):Scale 19 | { 20 | return switch (value) 21 | { 22 | case "1x": _1X; 23 | case "1.5x": _1_5X; 24 | case "2x": _2X; 25 | case "3x": _3X; 26 | case "4x": _4X; 27 | default: _1X; 28 | } 29 | } 30 | 31 | public function toString():String 32 | { 33 | return 34 | value == 1.0 ? "1x" : 35 | value == 1.5 ? "1.5x" : 36 | value == 2.0 ? "2x" : 37 | value == 3.0 ? "3x" : 38 | value == 4.0 ? "4x" : 39 | ""; 40 | } 41 | } -------------------------------------------------------------------------------- /com/stencyl/graphics/ScaleMode.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.graphics; 2 | 3 | @:enum abstract ScaleMode(Int) from Int to Int 4 | { 5 | public var NO_SCALING = 0; 6 | public var FULLSCREEN = 1; 7 | public var STRETCH_TO_FIT = 2; 8 | public var SCALE_TO_FIT_LETTERBOX = 3; 9 | public var SCALE_TO_FIT_FILL = 4; 10 | public var SCALE_TO_FIT_FULLSCREEN = 5; 11 | 12 | public function new(value:Int) this = value; 13 | 14 | @:from public static function fromString (value:String):ScaleMode 15 | { 16 | return switch (value) 17 | { 18 | case "NO_SCALING": NO_SCALING; 19 | case "FULLSCREEN": FULLSCREEN; 20 | case "STRETCH_TO_FIT": STRETCH_TO_FIT; 21 | case "SCALE_TO_FIT_LETTERBOX": SCALE_TO_FIT_LETTERBOX; 22 | case "SCALE_TO_FIT_FILL": SCALE_TO_FIT_FILL; 23 | case "SCALE_TO_FIT_FULLSCREEN": SCALE_TO_FIT_FULLSCREEN; 24 | default: NO_SCALING; 25 | } 26 | } 27 | 28 | @:to public function toString ():String 29 | { 30 | return switch (this) 31 | { 32 | case NO_SCALING: "NO_SCALING"; 33 | case FULLSCREEN: "FULLSCREEN"; 34 | case STRETCH_TO_FIT: "STRETCH_TO_FIT"; 35 | case SCALE_TO_FIT_LETTERBOX: "SCALE_TO_FIT_LETTERBOX"; 36 | case SCALE_TO_FIT_FILL: "SCALE_TO_FIT_FILL"; 37 | case SCALE_TO_FIT_FULLSCREEN: "SCALE_TO_FIT_FULLSCREEN"; 38 | default: "NO_SCALING"; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /com/stencyl/graphics/TileSource.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.graphics; 2 | 3 | #if use_tilemap 4 | 5 | import openfl.display.BitmapData; 6 | import openfl.display.Tileset; 7 | import openfl.geom.Rectangle; 8 | 9 | @:access(openfl.display.BitmapData) 10 | 11 | class TileSource 12 | { 13 | public var tileset:Tileset; 14 | public var tileID:Int; 15 | public var width:Int; 16 | public var height:Int; 17 | 18 | public function new() 19 | { 20 | 21 | } 22 | 23 | public static function fromBitmapData(img:BitmapData):TileSource 24 | { 25 | if(img.__tileSource == null) 26 | { 27 | var tileset = new Tileset(img); 28 | var ts = new TileSource(); 29 | ts.tileset = tileset; 30 | ts.tileID = tileset.addRect(img.rect); 31 | ts.width = img.width; 32 | ts.height = img.height; 33 | img.__tileSource = ts; 34 | } 35 | return img.__tileSource; 36 | } 37 | 38 | public static function createSubImage(img:BitmapData, x:Int, y:Int, width:Int, height:Int):BitmapData 39 | { 40 | var ts = fromBitmapData(img); 41 | var img = new BitmapData(0, 0, true, 0); 42 | img.__resize(width, height); 43 | 44 | var subTs = new TileSource(); 45 | subTs.tileset = ts.tileset; 46 | subTs.tileID = TilesetUtils.getSubFrame(ts.tileset, ts.tileID, x, y, width, height); 47 | subTs.width = width; 48 | subTs.height = height; 49 | img.__tileSource = subTs; 50 | return img; 51 | } 52 | } 53 | 54 | #end 55 | -------------------------------------------------------------------------------- /com/stencyl/graphics/TilesetUtils.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.graphics; 2 | 3 | import com.stencyl.utils.Log; 4 | 5 | import haxe.io.Bytes; 6 | 7 | import lime.graphics.Image; 8 | import lime.graphics.opengl.GLTexture; 9 | import lime.utils.UInt8Array; 10 | 11 | import openfl.display.BitmapData; 12 | import openfl.display.Tileset; 13 | import openfl.display3D.textures.TextureBase; 14 | import openfl.geom.Point; 15 | import openfl.geom.Rectangle; 16 | import openfl.utils.ByteArray; 17 | import openfl.utils.Endian; 18 | import openfl.Vector; 19 | 20 | @:access(openfl.display.BitmapData) 21 | @:access(openfl.display.Tileset) 22 | @:access(openfl.display3D.textures.TextureBase) 23 | 24 | class TilesetUtils 25 | { 26 | public static function getSubFrame(tileset:Tileset, frameId:Int, x:Int, y:Int, width:Int, height:Int):Int 27 | { 28 | var frameRect = tileset.getRect(frameId); 29 | var innerRect = new Rectangle(frameRect.x + x, frameRect.y + y, width, height); 30 | var existingInnerRectId = tileset.getRectID(innerRect); 31 | if(existingInnerRectId != null) 32 | return existingInnerRectId; 33 | return tileset.addRect(innerRect); 34 | } 35 | 36 | public static function updateFrameData(tileset:Tileset, frameId:Int, frameData:Image):Void 37 | { 38 | var gl = GLUtil.gl; 39 | var internalFormat = TextureBase.__textureInternalFormat; 40 | var format = TextureBase.__textureFormat; 41 | 42 | var textureBase = tileset.bitmapData.__texture; 43 | if(textureBase == null) 44 | textureBase = tileset.bitmapData.getTexture(GLUtil.context3D); 45 | var textureID = textureBase.__textureID; 46 | 47 | gl.bindTexture (gl.TEXTURE_2D, textureID); 48 | 49 | var r = tileset.getRect(frameId); 50 | 51 | gl.texSubImage2D(gl.TEXTURE_2D, 0, Std.int(r.x), Std.int(r.y), Std.int(r.width), Std.int(r.height), format, gl.UNSIGNED_BYTE, frameData.data); 52 | } 53 | } -------------------------------------------------------------------------------- /com/stencyl/graphics/fonts/FontSymbol.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.graphics.fonts; 2 | 3 | import openfl.display.BitmapData; 4 | 5 | class FontSymbol 6 | { 7 | #if use_tilemap 8 | 9 | /** 10 | * tile id in tileSheet 11 | */ 12 | public var tileID:Int; 13 | 14 | #else 15 | 16 | /** 17 | * symbol image 18 | */ 19 | public var bitmap:BitmapData; 20 | 21 | #end 22 | 23 | /** 24 | * x offset to draw symbol with 25 | */ 26 | public var xoffset:Int; 27 | 28 | /** 29 | * y offset to draw symbol with 30 | */ 31 | public var yoffset:Int; 32 | 33 | /** 34 | * how much to advance cursor after drawing symbol 35 | */ 36 | public var xadvance:Int; 37 | 38 | public function new() 39 | { 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /com/stencyl/graphics/shaders/BasicShader.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.graphics.shaders; 2 | 3 | import com.stencyl.Engine; 4 | 5 | class BasicShader 6 | { 7 | public var multipassParent:BasicShader; 8 | public var multipassTarget:BasicShader; 9 | public var model:PostProcess; 10 | 11 | public function new() 12 | { 13 | } 14 | 15 | public function setProperty(name:String, value:Dynamic) 16 | { 17 | model.setUniform(name, value); 18 | } 19 | 20 | public function getProperty(name:String):Dynamic 21 | { 22 | return model.getUniform(name); 23 | } 24 | 25 | public function tweenProperty(name:String, targetValue:Float, duration:Float = 1, easing:Dynamic = null) 26 | { 27 | model.tweenUniform(name, targetValue, duration, easing); 28 | } 29 | 30 | public function enable() 31 | { 32 | Engine.engine.addShader(model); 33 | } 34 | 35 | //Doesn't work. 36 | /*public function enableOnLayer(layerID:Int) 37 | { 38 | Engine.engine.clearShaders(); 39 | var layer = Engine.engine.layers.get(layerID); 40 | layer.addChild(model); 41 | Engine.engine.addShader(model, false); 42 | }*/ 43 | 44 | public function disable() 45 | { 46 | Engine.engine.clearShaders(); 47 | } 48 | 49 | //Some shaders need to be set to 0.001 to work properly. 50 | public function setTimeScale(amount:Float) 51 | { 52 | model.timeScale = amount; 53 | } 54 | 55 | //Enable only needs to be called on the final shader in the chain. 56 | public function combine(shader:BasicShader):BasicShader 57 | { 58 | multipassTarget = shader; 59 | shader.multipassParent = this; 60 | return shader; 61 | } 62 | } -------------------------------------------------------------------------------- /com/stencyl/graphics/shaders/BlurShader.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.graphics.shaders; 2 | 3 | class BlurShader extends BasicShader 4 | { 5 | public function new(radius:Float = 2.0, dirX:Float = 1.0, dirY:Float = 1.0) 6 | { 7 | super(); 8 | 9 | var script = " 10 | #ifdef GL_ES 11 | precision mediump float; 12 | #endif 13 | 14 | //in attributes from our vertex shader 15 | varying vec2 vTexCoord; 16 | 17 | //declare uniforms 18 | uniform sampler2D uImage0; 19 | uniform vec2 uResolution; 20 | 21 | uniform float radius; 22 | uniform float dirx; 23 | uniform float diry; 24 | 25 | void main() 26 | { 27 | //this will be our RGBA sum 28 | vec4 sum = vec4(0.0); 29 | 30 | //our original texcoord for this fragment 31 | vec2 tc = vTexCoord; 32 | 33 | //the amount to blur, i.e. how far off center to sample from 34 | //1.0 -> blur by one pixel 35 | //2.0 -> blur by two pixels, etc. 36 | float blur = radius / uResolution.x; 37 | 38 | //the direction of our blur 39 | //(1.0, 0.0) -> x-axis blur 40 | //(0.0, 1.0) -> y-axis blur 41 | float hstep = dirx; 42 | float vstep = diry; 43 | 44 | //apply blurring, using a 9-tap filter with predefined gaussian weights 45 | 46 | sum += texture2D(uImage0, vec2(tc.x - 4.0*blur*hstep, tc.y - 4.0*blur*vstep)) * 0.0162162162; 47 | sum += texture2D(uImage0, vec2(tc.x - 3.0*blur*hstep, tc.y - 3.0*blur*vstep)) * 0.0540540541; 48 | sum += texture2D(uImage0, vec2(tc.x - 2.0*blur*hstep, tc.y - 2.0*blur*vstep)) * 0.1216216216; 49 | sum += texture2D(uImage0, vec2(tc.x - 1.0*blur*hstep, tc.y - 1.0*blur*vstep)) * 0.1945945946; 50 | 51 | sum += texture2D(uImage0, vec2(tc.x, tc.y)) * 0.2270270270; 52 | 53 | sum += texture2D(uImage0, vec2(tc.x + 1.0*blur*hstep, tc.y + 1.0*blur*vstep)) * 0.1945945946; 54 | sum += texture2D(uImage0, vec2(tc.x + 2.0*blur*hstep, tc.y + 2.0*blur*vstep)) * 0.1216216216; 55 | sum += texture2D(uImage0, vec2(tc.x + 3.0*blur*hstep, tc.y + 3.0*blur*vstep)) * 0.0540540541; 56 | sum += texture2D(uImage0, vec2(tc.x + 4.0*blur*hstep, tc.y + 4.0*blur*vstep)) * 0.0162162162; 57 | 58 | //discard alpha for our simple demo, multiply by vertex color and return 59 | gl_FragColor = vec4(sum.rgb, 1.0); 60 | } 61 | "; 62 | 63 | model = new PostProcess(this, script, true); 64 | 65 | setRadius(radius); 66 | setDirectionX(dirX); 67 | setDirectionY(dirY); 68 | } 69 | 70 | public function setRadius(amount:Float) 71 | { 72 | setProperty("radius", amount); 73 | } 74 | 75 | public function setDirectionX(amount:Float) 76 | { 77 | setProperty("dirx", amount); 78 | } 79 | 80 | public function setDirectionY(amount:Float) 81 | { 82 | setProperty("diry", amount); 83 | } 84 | } -------------------------------------------------------------------------------- /com/stencyl/graphics/shaders/CSBShader.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.graphics.shaders; 2 | 3 | class CSBShader extends BasicShader 4 | { 5 | //Helper function for blocks 6 | public static function create(type:String = "contrast", amount:Float = 1.0):CSBShader 7 | { 8 | if(type == "contrast") 9 | { 10 | return new CSBShader(amount, 1.0, 1.0); 11 | } 12 | 13 | else if(type == "saturation") 14 | { 15 | return new CSBShader(1.0, 1.0, amount); 16 | } 17 | 18 | return new CSBShader(1.0, amount, 1.0); 19 | } 20 | 21 | public function new(contrast:Float = 1.0, brightness:Float = 1.0, saturation:Float = 1.0) 22 | { 23 | super(); 24 | 25 | var script = " 26 | #ifdef GL_ES 27 | precision mediump float; 28 | #endif 29 | 30 | varying vec2 vTexCoord; 31 | uniform sampler2D uImage0; 32 | uniform float contrast; 33 | uniform float brightness; 34 | uniform float saturation; 35 | 36 | vec3 _mix(vec3 a, vec3 b, float amount) 37 | { 38 | return vec3(a.x * (1.0 - amount) + b.x * amount, a.y * (1.0 - amount) + b.y * amount, a.z * (1.0 - amount) + b.z * amount); 39 | } 40 | 41 | void main() 42 | { 43 | vec3 color = texture2D(uImage0, vTexCoord).rgb; 44 | const vec3 luminanceCoefficient = vec3(0.2125, 0.7154, 0.0721); 45 | vec3 avgLuminance = vec3(0.5, 0.5, 0.5); 46 | 47 | vec3 brtColor = vec3(color.x * brightness, color.y * brightness, color.z * brightness); 48 | vec3 intensity = vec3(dot(brtColor, luminanceCoefficient)); 49 | vec3 satColor = _mix(intensity, brtColor, saturation); 50 | vec3 conColor = _mix(avgLuminance, satColor, contrast); 51 | 52 | gl_FragColor = vec4(conColor, 1); 53 | } 54 | "; 55 | 56 | model = new PostProcess(this, script, true); 57 | 58 | setContrast(contrast); 59 | setBrightness(brightness); 60 | setSaturation(saturation); 61 | } 62 | 63 | public function setContrast(amount:Float) 64 | { 65 | setProperty("contrast", amount); 66 | } 67 | 68 | public function setBrightness(amount:Float) 69 | { 70 | setProperty("brightness", amount); 71 | } 72 | 73 | public function setSaturation(amount:Float) 74 | { 75 | setProperty("saturation", amount); 76 | } 77 | } -------------------------------------------------------------------------------- /com/stencyl/graphics/shaders/ExternalShader.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.graphics.shaders; 2 | 3 | class ExternalShader extends BasicShader 4 | { 5 | public function new(scriptPath:String) 6 | { 7 | super(); 8 | scriptPath = "assets/data/" + scriptPath; 9 | model = new PostProcess(this, scriptPath); 10 | } 11 | } -------------------------------------------------------------------------------- /com/stencyl/graphics/shaders/GrayscaleShader.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.graphics.shaders; 2 | 3 | class GrayscaleShader extends BasicShader 4 | { 5 | public function new() 6 | { 7 | super(); 8 | 9 | var script = " 10 | #ifdef GL_ES 11 | precision mediump float; 12 | #endif 13 | 14 | varying vec2 vTexCoord; 15 | uniform sampler2D uImage0; 16 | 17 | void main(void) 18 | { 19 | vec4 color = texture2D(uImage0, vTexCoord); 20 | float gray = dot(color.rgb, vec3(0.299, 0.587, 0.114)); 21 | gl_FragColor = vec4(gray, gray, gray, 1.0); 22 | } 23 | "; 24 | 25 | model = new PostProcess(this, script, true); 26 | } 27 | } -------------------------------------------------------------------------------- /com/stencyl/graphics/shaders/HueShader.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.graphics.shaders; 2 | 3 | class HueShader extends BasicShader 4 | { 5 | public function new(hue:Float = 0, asDegrees:Bool = true) 6 | { 7 | super(); 8 | 9 | if(asDegrees) 10 | { 11 | hue = Math.PI / 180 * hue; 12 | } 13 | 14 | var script = " 15 | #ifdef GL_ES 16 | precision mediump float; 17 | #endif 18 | 19 | varying vec2 vTexCoord; 20 | uniform sampler2D uImage0; 21 | 22 | uniform float hue; 23 | const mat3 rgb2yiq = mat3(0.299, 0.587, 0.114, 0.595716, -0.274453, -0.321263, 0.211456, -0.522591, 0.311135); 24 | const mat3 yiq2rgb = mat3(1.0, 0.9563, 0.6210, 1.0, -0.2721, -0.6474, 1.0, -1.1070, 1.7046); 25 | 26 | void main() 27 | { 28 | vec3 color = texture2D(uImage0, vTexCoord).rgb; 29 | vec3 yColor = rgb2yiq * color; 30 | 31 | float originalHue = atan(yColor.b, yColor.g); 32 | float finalHue = originalHue + hue; 33 | float chroma = sqrt(yColor.b * yColor.b + yColor.g * yColor.g); 34 | 35 | vec3 yFinalColor = vec3(yColor.r, chroma * cos(finalHue), chroma * sin(finalHue)); 36 | gl_FragColor = vec4(yiq2rgb * yFinalColor, 1.0); 37 | } 38 | "; 39 | 40 | model = new PostProcess(this, script, true); 41 | 42 | setHue(hue, false); 43 | } 44 | 45 | //Passed in degrees 46 | public function setHue(amount:Float, asDegrees:Bool = true) 47 | { 48 | if(asDegrees) 49 | { 50 | amount = Math.PI / 180 * amount; 51 | } 52 | 53 | setProperty("hue", amount); 54 | } 55 | } -------------------------------------------------------------------------------- /com/stencyl/graphics/shaders/InlineShader.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.graphics.shaders; 2 | 3 | class InlineShader extends BasicShader 4 | { 5 | public function new(script:String) 6 | { 7 | super(); 8 | model = new PostProcess(this, script, true); 9 | } 10 | } -------------------------------------------------------------------------------- /com/stencyl/graphics/shaders/InvertShader.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.graphics.shaders; 2 | 3 | class InvertShader extends BasicShader 4 | { 5 | public function new() 6 | { 7 | super(); 8 | 9 | var script = " 10 | #ifdef GL_ES 11 | precision mediump float; 12 | #endif 13 | 14 | varying vec2 vTexCoord; 15 | uniform sampler2D uImage0; 16 | 17 | void main(void) 18 | { 19 | vec4 color = texture2D(uImage0, vTexCoord); 20 | gl_FragColor = vec4(vec3(1.0, 1.0, 1.0) - color.rgb, color.a); 21 | } 22 | "; 23 | 24 | model = new PostProcess(this, script, true); 25 | } 26 | } -------------------------------------------------------------------------------- /com/stencyl/graphics/shaders/ScanlineShader.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.graphics.shaders; 2 | 3 | class ScanlineShader extends BasicShader 4 | { 5 | public function new(scale:Float = 1.0) 6 | { 7 | super(); 8 | 9 | var script = " 10 | #ifdef GL_ES 11 | precision mediump float; 12 | #endif 13 | 14 | varying vec2 vTexCoord; 15 | uniform vec2 uResolution; 16 | uniform sampler2D uImage0; 17 | 18 | uniform float scale; 19 | 20 | void main() 21 | { 22 | if (mod(floor(vTexCoord.y * uResolution.y / scale), 2.0) == 0.0) 23 | gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); 24 | else 25 | gl_FragColor = texture2D(uImage0, vTexCoord); 26 | } 27 | "; 28 | 29 | model = new PostProcess(this, script, true); 30 | 31 | setScale(scale); 32 | } 33 | 34 | public function setScale(amount:Float) 35 | { 36 | setProperty("scale", amount); 37 | } 38 | } -------------------------------------------------------------------------------- /com/stencyl/graphics/shaders/SepiaShader.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.graphics.shaders; 2 | 3 | class SepiaShader extends BasicShader 4 | { 5 | public function new() 6 | { 7 | super(); 8 | 9 | var script = " 10 | #ifdef GL_ES 11 | precision mediump float; 12 | #endif 13 | 14 | varying vec2 vTexCoord; 15 | uniform sampler2D uImage0; 16 | 17 | void main(void) 18 | { 19 | vec4 color = texture2D(uImage0, vTexCoord); 20 | gl_FragColor.r = dot(color, vec4(0.393,0.769,0.189,0)); 21 | gl_FragColor.g = dot(color, vec4(0.349,0.686,0.168,0)); 22 | gl_FragColor.b = dot(color, vec4(0.272,0.534,0.131,0)); 23 | gl_FragColor.a = color.a; 24 | } 25 | "; 26 | 27 | model = new PostProcess(this, script, true); 28 | } 29 | } -------------------------------------------------------------------------------- /com/stencyl/graphics/shaders/SharpenShader.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.graphics.shaders; 2 | 3 | class SharpenShader extends BasicShader 4 | { 5 | public function new(amount:Float = 2.0) 6 | { 7 | super(); 8 | 9 | var script = " 10 | #ifdef GL_ES 11 | precision mediump float; 12 | #endif 13 | 14 | varying vec2 vTexCoord; 15 | uniform sampler2D uImage0; 16 | uniform vec2 uResolution; 17 | 18 | uniform float amount; 19 | 20 | void main() 21 | { 22 | //this will be our RGBA sum 23 | vec4 sum = vec4(0.0); 24 | 25 | //our original texcoord for this fragment 26 | vec2 tc = vTexCoord; 27 | 28 | float reach = 1.0 / uResolution.x; 29 | 30 | //current pixel 31 | sum += texture2D(uImage0, vec2(tc.x, tc.y)); 32 | 33 | //sharpen 34 | sum += (texture2D(uImage0, vec2(tc.x, tc.y)) - texture2D(uImage0, vec2(tc.x + 1.0 * reach, tc.y))) * amount; 35 | sum += (texture2D(uImage0, vec2(tc.x, tc.y)) - texture2D(uImage0, vec2(tc.x - 1.0 * reach, tc.y))) * amount; 36 | sum += (texture2D(uImage0, vec2(tc.x, tc.y)) - texture2D(uImage0, vec2(tc.x, tc.y + 1.0 * reach))) * amount; 37 | sum += (texture2D(uImage0, vec2(tc.x, tc.y)) - texture2D(uImage0, vec2(tc.x, tc.y - 1.0 * reach))) * amount; 38 | 39 | gl_FragColor = vec4(sum.rgb, 1.0); 40 | } 41 | "; 42 | 43 | model = new PostProcess(this, script, true); 44 | 45 | setAmount(amount); 46 | } 47 | 48 | public function setAmount(amount:Float) 49 | { 50 | setProperty("amount", amount); 51 | } 52 | } -------------------------------------------------------------------------------- /com/stencyl/graphics/shaders/TintShader.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.graphics.shaders; 2 | 3 | import com.stencyl.utils.Utils; 4 | 5 | class TintShader extends BasicShader 6 | { 7 | public function new(color:Int, amount:Float = 1.0) 8 | { 9 | super(); 10 | 11 | var script = " 12 | #ifdef GL_ES 13 | precision mediump float; 14 | #endif 15 | 16 | varying vec2 vTexCoord; 17 | uniform sampler2D uImage0; 18 | uniform float amount; 19 | uniform float red; 20 | uniform float green; 21 | uniform float blue; 22 | 23 | vec3 _mix(vec3 a, vec3 b, float amount) 24 | { 25 | return vec3(a.x * (1.0 - amount) + b.x * amount, a.y * (1.0 - amount) + b.y * amount, a.z * (1.0 - amount) + b.z * amount); 26 | } 27 | 28 | void main() 29 | { 30 | vec3 color = texture2D(uImage0, vTexCoord).rgb; 31 | vec3 endColor = _mix(color, vec3(red, green, blue), amount); 32 | gl_FragColor = vec4(endColor.x, endColor.y, endColor.z, 1); 33 | } 34 | "; 35 | 36 | model = new PostProcess(this, script, true); 37 | 38 | setColor(color); 39 | setAmount(amount); 40 | } 41 | 42 | public function setAmount(amount:Float) 43 | { 44 | setProperty("amount", amount); 45 | } 46 | 47 | public function setColor(color:Int) 48 | { 49 | setProperty("red", Utils.getRed(color)/255.0); 50 | setProperty("green", Utils.getGreen(color)/255.0); 51 | setProperty("blue", Utils.getBlue(color)/255.0); 52 | } 53 | } -------------------------------------------------------------------------------- /com/stencyl/graphics/transitions/CircleTransition.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.graphics.transitions; 2 | 3 | import openfl.display.Graphics; 4 | import openfl.display.Bitmap; 5 | import openfl.display.BitmapData; 6 | import openfl.geom.ColorTransform; 7 | import openfl.display.Shape; 8 | import openfl.display.BlendMode; 9 | import openfl.display.Shape; 10 | import openfl.geom.Point; 11 | import openfl.geom.Rectangle; 12 | 13 | import com.stencyl.Engine; 14 | import com.stencyl.utils.Utils; 15 | import com.stencyl.utils.motion.*; 16 | 17 | class CircleTransition extends Transition 18 | { 19 | public var color:Int; 20 | public var radius:TweenFloat; 21 | 22 | private var beginRadius:Int; 23 | private var endRadius:Int; 24 | private var circleImg:BitmapData; 25 | private var s:Shape; 26 | 27 | public function new(direction:String, duration:Float, color:Int=0xff000000) 28 | { 29 | super(duration); 30 | 31 | this.color = color; 32 | this.direction = direction; 33 | 34 | if(direction == Transition.IN) 35 | { 36 | beginRadius = 0; 37 | endRadius = Std.int(Math.ceil(Point.distance(new Point(0, 0), new Point(Engine.screenWidthHalf * Engine.SCALE, Engine.screenHeightHalf * Engine.SCALE)))); 38 | } 39 | 40 | else if(direction == Transition.OUT) 41 | { 42 | beginRadius = Std.int(Math.ceil(Point.distance(new Point(0, 0), new Point(Engine.screenWidthHalf * Engine.SCALE, Engine.screenHeightHalf * Engine.SCALE)))); 43 | endRadius = 0; 44 | } 45 | } 46 | 47 | override public function start() 48 | { 49 | active = true; 50 | 51 | s = new Shape(); 52 | circleImg = new BitmapData(Std.int(Engine.screenWidth * Engine.SCALE), Std.int(Engine.screenHeight * Engine.SCALE)); 53 | radius = new TweenFloat(); 54 | 55 | if (direction == Transition.IN) 56 | { 57 | var graphics:Graphics = s.graphics; 58 | graphics.beginFill(color); 59 | graphics.drawRect(0, 0, Engine.screenWidth * Engine.SCALE, Engine.screenHeight * Engine.SCALE); 60 | graphics.endFill(); 61 | } 62 | 63 | Engine.engine.transitionLayer.addChild(s); 64 | 65 | //--- 66 | 67 | radius.tween(beginRadius, endRadius, Easing.linear, Std.int(duration*1000)).doOnComplete(stop); 68 | } 69 | 70 | override public function draw(g:Graphics) 71 | { 72 | s.graphics.clear(); 73 | 74 | s.graphics.beginFill(color); 75 | s.graphics.drawRect(0, 0, Engine.screenWidth * Engine.SCALE, Engine.screenHeight * Engine.SCALE); 76 | s.graphics.endFill(); 77 | 78 | circleImg.draw(Engine.engine.colorLayer); 79 | circleImg.draw(Engine.engine.master); 80 | s.graphics.beginBitmapFill(circleImg); 81 | s.graphics.drawCircle(Engine.screenWidthHalf * Engine.SCALE, Engine.screenHeightHalf * Engine.SCALE, radius.value); 82 | s.graphics.endFill(); 83 | } 84 | 85 | override public function cleanup() 86 | { 87 | if(s != null) 88 | { 89 | Engine.engine.transitionLayer.removeChild(s); 90 | s = null; 91 | } 92 | } 93 | } -------------------------------------------------------------------------------- /com/stencyl/graphics/transitions/CrossfadeTransition.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.graphics.transitions; 2 | 3 | import openfl.display.Sprite; 4 | import openfl.display.Graphics; 5 | import openfl.display.BitmapData; 6 | import openfl.geom.ColorTransform; 7 | import openfl.display.Shape; 8 | import openfl.geom.Transform; 9 | 10 | import com.stencyl.Engine; 11 | import com.stencyl.utils.motion.*; 12 | 13 | class CrossfadeTransition extends Transition 14 | { 15 | private var oldImg:Sprite; 16 | private var bitmap:BitmapData; 17 | 18 | public var rect:Shape; 19 | public var rectAlpha:TweenFloat; 20 | 21 | public function new(oldImg:Sprite, duration:Float) 22 | { 23 | super(duration); 24 | 25 | this.oldImg = oldImg; 26 | } 27 | 28 | override public function start() 29 | { 30 | active = true; 31 | 32 | bitmap = new BitmapData(Std.int(Engine.screenWidth * Engine.SCALE), Std.int(Engine.screenHeight * Engine.SCALE)); 33 | bitmap.draw(oldImg); 34 | 35 | rect = new Shape(); 36 | var g = rect.graphics; 37 | g.beginBitmapFill(bitmap); 38 | g.drawRect(0, 0, Engine.screenWidth * Engine.SCALE, Engine.screenHeight * Engine.SCALE); 39 | g.endFill(); 40 | 41 | Engine.engine.transitionLayer.addChild(rect); 42 | 43 | rectAlpha = new TweenFloat(); 44 | rectAlpha.tween(1, 0, Easing.linear, Std.int(duration*1000)).doOnComplete(stop); 45 | } 46 | 47 | override public function update(elapsedTime:Float) 48 | { 49 | rect.alpha = rectAlpha.value; 50 | } 51 | 52 | override public function draw(g:Graphics) 53 | { 54 | } 55 | 56 | override public function cleanup() 57 | { 58 | oldImg = null; 59 | bitmap = null; 60 | 61 | if(rect != null) 62 | { 63 | Engine.engine.transitionLayer.removeChild(rect); 64 | rect = null; 65 | } 66 | } 67 | 68 | } -------------------------------------------------------------------------------- /com/stencyl/graphics/transitions/FadeInTransition.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.graphics.transitions; 2 | 3 | import openfl.display.BitmapData; 4 | import openfl.geom.ColorTransform; 5 | import openfl.display.Shape; 6 | 7 | import com.stencyl.Engine; 8 | import com.stencyl.utils.motion.*; 9 | 10 | class FadeInTransition extends Transition 11 | { 12 | public var color:Int; 13 | public var rect:Shape; 14 | public var rectAlpha:TweenFloat; 15 | 16 | public function new(duration:Float, color:Int=0xff000000) 17 | { 18 | super(duration); 19 | 20 | this.color = color; 21 | this.direction = Transition.IN; 22 | } 23 | 24 | override public function start() 25 | { 26 | active = true; 27 | 28 | rect = new Shape(); 29 | var g = rect.graphics; 30 | 31 | g.beginFill(color); 32 | g.drawRect(0, 0, Engine.screenWidth * Engine.SCALE + 4, Engine.screenHeight * Engine.SCALE + 4); 33 | g.endFill(); 34 | 35 | Engine.engine.transitionLayer.addChild(rect); 36 | 37 | rectAlpha = new TweenFloat(); 38 | rectAlpha.tween(1, 0, Easing.linear, Std.int(duration*1000)).doOnComplete(stop); 39 | } 40 | 41 | override public function update(elapsedTime:Float) 42 | { 43 | rect.alpha = rectAlpha.value; 44 | } 45 | 46 | override public function cleanup() 47 | { 48 | if(rect != null) 49 | { 50 | Engine.engine.transitionLayer.removeChild(rect); 51 | rect = null; 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /com/stencyl/graphics/transitions/FadeOutTransition.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.graphics.transitions; 2 | 3 | import openfl.display.BitmapData; 4 | import openfl.geom.ColorTransform; 5 | import openfl.display.Shape; 6 | 7 | import com.stencyl.Engine; 8 | import com.stencyl.utils.motion.*; 9 | 10 | class FadeOutTransition extends Transition 11 | { 12 | public var color:Int; 13 | public var rect:Shape; 14 | public var rectAlpha:TweenFloat; 15 | 16 | public function new(duration:Float, color:Int=0xff000000) 17 | { 18 | super(duration); 19 | 20 | this.color = color; 21 | this.direction = Transition.IN; 22 | } 23 | 24 | override public function start() 25 | { 26 | active = true; 27 | 28 | rect = new Shape(); 29 | rect.alpha = 0; 30 | var g = rect.graphics; 31 | 32 | g.beginFill(color); 33 | g.drawRect(0, 0, Engine.screenWidth * Engine.SCALE + 4, Engine.screenHeight * Engine.SCALE + 4); 34 | g.endFill(); 35 | 36 | Engine.engine.transitionLayer.addChild(rect); 37 | 38 | rectAlpha = new TweenFloat(); 39 | rectAlpha.tween(0, 1, Easing.linear, Std.int(duration*1000)).doOnComplete(stop); 40 | } 41 | 42 | override public function update(elapsedTime:Float) 43 | { 44 | rect.alpha = rectAlpha.value; 45 | } 46 | 47 | override public function cleanup() 48 | { 49 | if(rect != null) 50 | { 51 | Engine.engine.transitionLayer.removeChild(rect); 52 | rect = null; 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /com/stencyl/graphics/transitions/Transition.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.graphics.transitions; 2 | 3 | import openfl.display.Graphics; 4 | 5 | class Transition 6 | { 7 | public var duration:Float; 8 | public var direction:String; 9 | 10 | var active:Bool; 11 | var complete:Bool; 12 | 13 | public static var IN:String = "in"; 14 | public static var OUT:String = "out"; 15 | public static var THROUGH:String = "through"; 16 | 17 | public function new(duration:Float) 18 | { 19 | this.duration = duration; 20 | active = false; 21 | complete = false; 22 | 23 | if(duration == 0) 24 | { 25 | complete = true; 26 | active = true; 27 | } 28 | } 29 | 30 | public function start() 31 | { 32 | // complete = true; 33 | } 34 | 35 | public function reset() 36 | { 37 | complete = false; 38 | } 39 | 40 | public function stop() 41 | { 42 | complete = true; 43 | } 44 | 45 | public function deactivate() 46 | { 47 | active = false; 48 | } 49 | 50 | //Usually hides the transition 51 | public function cleanup() 52 | { 53 | } 54 | 55 | public function isActive():Bool 56 | { 57 | return active; 58 | } 59 | 60 | public function isComplete():Bool 61 | { 62 | return complete; 63 | } 64 | 65 | public function update(elapsedTime:Float) 66 | { 67 | } 68 | 69 | public function draw(g:Graphics) 70 | { 71 | } 72 | 73 | public function getDuration():Float 74 | { 75 | return duration; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /com/stencyl/io/AbstractReader.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io; 2 | 3 | import com.stencyl.models.Resource; 4 | 5 | interface AbstractReader 6 | { 7 | function accepts(type:String):Bool; 8 | function read(object:Dynamic):Resource; 9 | } 10 | -------------------------------------------------------------------------------- /com/stencyl/io/ActorTypeReader.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io; 2 | 3 | import com.stencyl.utils.Utils; 4 | 5 | import com.stencyl.models.PhysicsMode; 6 | import com.stencyl.models.Resource; 7 | import com.stencyl.models.actor.ActorType; 8 | import com.stencyl.io.mbs.actortype.MbsActorType; 9 | import com.stencyl.io.mbs.actortype.MbsActorType.*; 10 | import com.stencyl.behavior.BehaviorInstance; 11 | 12 | import box2D.dynamics.B2Body; 13 | import box2D.dynamics.B2BodyDef; 14 | 15 | class ActorTypeReader implements AbstractReader 16 | { 17 | public function new() 18 | { 19 | } 20 | 21 | public function accepts(type:String):Bool 22 | { 23 | return type == MBS_ACTOR_TYPE.getName(); 24 | } 25 | 26 | public function read(obj:Dynamic):Resource 27 | { 28 | //Log.verbose("Reading ActorType (" + ID + ") - " + name); 29 | 30 | var r:MbsActorType = cast obj; 31 | 32 | var id = r.getId(); 33 | var atlasID = r.getAtlasID(); 34 | var name = r.getName(); 35 | 36 | var bodyDef = new B2BodyDef(); 37 | 38 | bodyDef.fixedRotation = r.getFixedRotation(); 39 | 40 | bodyDef.type = switch(r.getBodyType()) 41 | { 42 | case 0: B2Body.b2_staticBody; 43 | case 1: B2Body.b2_kinematicBody; 44 | default: B2Body.b2_dynamicBody; 45 | } 46 | 47 | bodyDef.linearDamping = r.getLinearDamping(); 48 | bodyDef.angularDamping = r.getAngularDamping(); 49 | 50 | bodyDef.friction = r.getFriction(); 51 | bodyDef.bounciness = r.getRestitution(); 52 | bodyDef.mass = r.getMass(); 53 | bodyDef.aMass = r.getInertia(); 54 | 55 | bodyDef.active = true; 56 | bodyDef.bullet = false; 57 | bodyDef.allowSleep = false; 58 | bodyDef.awake = true; 59 | bodyDef.ignoreGravity = r.getIgnoreGravity(); 60 | bodyDef.bullet = r.getContinuous(); 61 | 62 | var spriteID:Int = r.getSprite(); 63 | var groupID:Int = r.getGroupID(); 64 | var physicsMode:PhysicsMode = r.getPhysicsMode(); 65 | var autoScale:Bool = r.getAutoScale(); 66 | var pausable:Bool = r.getPausable(); 67 | var ignoreGravity:Bool = bodyDef.ignoreGravity || bodyDef.type == B2Body.b2_staticBody || bodyDef.type == B2Body.b2_kinematicBody; 68 | 69 | //These are more like behavior instances 70 | //They reference the Behavior + Map of instance values 71 | var behaviorValues = AttributeValues.readBehaviors(r.getSnippets()); 72 | 73 | var eventID:Int = r.getEventSnippetID(); 74 | 75 | if(eventID > -1) 76 | { 77 | behaviorValues.set(""+eventID, new BehaviorInstance(eventID, new Map())); 78 | } 79 | 80 | return new ActorType(id, atlasID, name, groupID, spriteID, behaviorValues, bodyDef, physicsMode, autoScale, pausable, ignoreGravity); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /com/stencyl/io/BackgroundReader.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io; 2 | 3 | import com.stencyl.utils.Utils; 4 | 5 | import com.stencyl.models.Resource; 6 | import com.stencyl.io.mbs.MbsBackground; 7 | import com.stencyl.io.mbs.MbsBackground.*; 8 | import com.stencyl.models.background.ColorBackground; 9 | import com.stencyl.models.background.GradientBackground; 10 | import com.stencyl.models.background.ImageBackground; 11 | import com.stencyl.models.background.ScrollingBackground; 12 | 13 | class BackgroundReader implements AbstractReader 14 | { 15 | public function new() 16 | { 17 | } 18 | 19 | public function accepts(type:String):Bool 20 | { 21 | return type == MBS_BACKGROUND.getName(); 22 | } 23 | 24 | public function read(obj:Dynamic):Resource 25 | { 26 | //Log.verbose("Reading Background (" + ID + ") - " + name); 27 | 28 | var r:MbsBackground = cast obj; 29 | 30 | var id = r.getId(); 31 | var atlasID = r.getAtlasID(); 32 | var name = r.getName(); 33 | 34 | var scrollX = r.getXVelocity(); 35 | var scrollY = r.getYVelocity(); 36 | var parallaxX = r.getXParallaxFactor(); 37 | var parallaxY = r.getYParallaxFactor(); 38 | var numFrames = r.getNumFrames(); 39 | var durations = new Array(); 40 | var frameData = new Array(); 41 | 42 | if(numFrames > 0) 43 | { 44 | var intList = r.getDurations(); 45 | for(i in 0...intList.length()) 46 | durations.push(intList.readInt()); 47 | } 48 | 49 | var repeats = r.getRepeats(); 50 | 51 | if(scrollX != 0 || scrollY != 0) 52 | { 53 | return new ScrollingBackground(id, atlasID, name, durations, parallaxX, parallaxY, repeats, scrollX, scrollY); 54 | } 55 | 56 | else 57 | { 58 | return new ImageBackground(id, atlasID, name, durations, parallaxX, parallaxY, repeats); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /com/stencyl/io/BehaviorReader.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io; 2 | 3 | import com.stencyl.io.mbs.snippet.*; 4 | import com.stencyl.models.Resource; 5 | import com.stencyl.behavior.Behavior; 6 | import com.stencyl.behavior.Attribute; 7 | 8 | class BehaviorReader 9 | { 10 | public function new() 11 | { 12 | } 13 | 14 | public static function readBehavior(r:MbsSnippetDef):Behavior 15 | { 16 | var elementID = r.getId(); 17 | var name = r.getName(); 18 | var classname = r.getPackageName() + "." + r.getClassname(); 19 | var isEvent = r.getAttachedEvent(); 20 | 21 | var attributes:Map = new Map(); 22 | var type = r.getType(); 23 | 24 | var attrList = r.getAttributes(); 25 | for(i in 0...attrList.length()) 26 | { 27 | var attrReader = attrList.getNextObject(); 28 | attributes.set(""+attrReader.getId(), readAttribute(attrReader, isEvent)); 29 | } 30 | 31 | var b:Behavior = new Behavior 32 | ( 33 | null, 34 | null, 35 | elementID, 36 | name, 37 | classname, 38 | true, 39 | true, 40 | attributes, 41 | type, 42 | isEvent 43 | ); 44 | 45 | return b; 46 | } 47 | 48 | public static function readAttribute(r:MbsAttributeDef, isEvent:Bool):Attribute 49 | { 50 | var ID = r.getId(); 51 | var fieldName = r.getName(); 52 | var fullName = r.getFullname(); 53 | var hidden = isEvent || r.getHidden(); 54 | var type = r.getType(); 55 | var defaultValue = AttributeValues.readAttributeDef(type, r); 56 | 57 | return new Attribute(ID, fieldName, fullName, defaultValue, type, null, hidden); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /com/stencyl/io/FontReader.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io; 2 | 3 | import com.stencyl.io.mbs.MbsFont; 4 | import com.stencyl.io.mbs.MbsFont.*; 5 | import com.stencyl.models.Font; 6 | import com.stencyl.models.Resource; 7 | 8 | class FontReader implements AbstractReader 9 | { 10 | public function new() 11 | { 12 | } 13 | 14 | public function accepts(type:String):Bool 15 | { 16 | return type == MBS_FONT.getName(); 17 | } 18 | 19 | public function read(obj:Dynamic):Resource 20 | { 21 | //Log.verbose("Reading Font (" + ID + ") - " + name); 22 | 23 | var r:MbsFont = cast obj; 24 | 25 | return new Font(r.getId(), r.getAtlasID(), r.getName(), false); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /com/stencyl/io/SoundReader.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io; 2 | 3 | import com.stencyl.utils.Utils; 4 | 5 | import com.stencyl.io.mbs.MbsMusic; 6 | import com.stencyl.io.mbs.MbsMusic.*; 7 | import com.stencyl.models.Resource; 8 | import com.stencyl.models.Sound; 9 | 10 | class SoundReader implements AbstractReader 11 | { 12 | public function new() 13 | { 14 | } 15 | 16 | public function accepts(type:String):Bool 17 | { 18 | return type == MBS_MUSIC.getName(); 19 | } 20 | 21 | public function read(obj:Dynamic):Resource 22 | { 23 | //Log.verbose("Reading Sound (" + ID + ") - " + name); 24 | 25 | var r:MbsMusic = cast obj; 26 | 27 | var streaming = r.getStream(); 28 | var looping = r.getLoop(); 29 | var panning:Float = r.getPan(); 30 | var volume:Float = r.getVolume(); 31 | var ext = r.getType(); 32 | var s = new Sound(r.getId(), r.getName(), streaming, looping, panning, volume, ext, r.getAtlasID()); 33 | 34 | return s; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /com/stencyl/io/TilesetReader.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io; 2 | 3 | import com.stencyl.utils.Utils; 4 | 5 | import com.stencyl.io.mbs.scene.*; 6 | import com.stencyl.io.mbs.scene.MbsTileset.*; 7 | import com.stencyl.models.GameModel; 8 | import com.stencyl.models.Resource; 9 | import com.stencyl.models.scene.AutotileFormat; 10 | import com.stencyl.models.scene.Tileset; 11 | import com.stencyl.models.scene.Tile; 12 | 13 | class TilesetReader implements AbstractReader 14 | { 15 | public function new() 16 | { 17 | } 18 | 19 | public function accepts(type:String):Bool 20 | { 21 | return type == MBS_TILESET.getName(); 22 | } 23 | 24 | public function read(obj:Dynamic):Resource 25 | { 26 | //Log.verbose("Reading Tileset (" + ID + ") - " + name); 27 | 28 | var r:MbsTileset = cast obj; 29 | 30 | var framesAcross = r.getAcross(); 31 | var framesDown = r.getDown(); 32 | var tileWidth = r.getTileWidth(); 33 | var tileHeight = r.getTileHeight(); 34 | var readable = r.getReadableImages(); 35 | var tiles = new Array(); 36 | 37 | var tset = new Tileset(r.getId(), r.getAtlasID(), r.getName(), framesAcross, framesDown, tileWidth, tileHeight, readable, tiles); 38 | 39 | var tileList = r.getTiles(); 40 | 41 | for(i in 0...tileList.length()) 42 | { 43 | var tileReader = tileList.getNextObject(); 44 | tiles[tileReader.getId()] = readTile(tileReader, tset); 45 | } 46 | 47 | if(tset.isAtlasActive()) 48 | { 49 | tset.loadGraphics(); 50 | } 51 | 52 | return tset; 53 | } 54 | 55 | public function readTile(r:MbsTile, parent:Tileset):Tile 56 | { 57 | var tileID = r.getId(); 58 | var collisionID = r.getCollision(); 59 | var metadata = r.getMetadata(); 60 | //Always single for now! 61 | var frameID = r.getFrames(); 62 | 63 | //Animated Tiles 64 | var imgData:Dynamic = null; 65 | var durations = new Array(); 66 | var counter = 0; 67 | 68 | var durList = r.getDurations(); 69 | for(i in 0...durList.length()) 70 | { 71 | //Round to the nearest 10ms - there's no more granularity than this and makes it much easier for me. 72 | durations[counter] = durList.readInt(); 73 | 74 | durations[counter] = Math.floor(durations[counter] / 10); 75 | durations[counter] *= 10; 76 | 77 | counter++; 78 | } 79 | 80 | var autotileFormat:AutotileFormat = null; 81 | if(r.getAutotile() != -1) 82 | autotileFormat = GameModel.get().autotileFormats.get(r.getAutotile()); 83 | 84 | var autotileMergeSet:Map = null; 85 | if(r.getAutotileMerge().length() != 0) 86 | { 87 | autotileMergeSet = new Map(); 88 | var mergeList = r.getAutotileMerge(); 89 | for(i in 0...mergeList.length()) 90 | { 91 | var mergeID = mergeList.readInt(); 92 | autotileMergeSet.set(mergeID, mergeID); 93 | } 94 | } 95 | 96 | return new Tile(tileID, collisionID, metadata, frameID, durations, autotileFormat, autotileMergeSet, parent); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /com/stencyl/io/mbs/MbsBlank.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io.mbs; 2 | 3 | import mbs.core.ComposedType; 4 | import mbs.core.MbsField; 5 | import mbs.core.MbsObject; 6 | import mbs.core.MbsType; 7 | import mbs.core.MbsTypes.*; 8 | import mbs.io.MbsIO; 9 | import mbs.io.MbsList; 10 | 11 | class MbsBlank extends MbsObject 12 | { 13 | public static var name:MbsField; 14 | public static var type:MbsField; 15 | 16 | public static var MBS_BLANK:ComposedType; 17 | public static function initializeType():Void 18 | { 19 | if(MBS_BLANK != null) return; 20 | MBS_BLANK = new ComposedType("MbsBlank"); 21 | MBS_BLANK.setInstantiator(function(data) return new MbsBlank(data)); 22 | 23 | name = MBS_BLANK.createField("name", STRING); 24 | type = MBS_BLANK.createField("type", STRING); 25 | 26 | } 27 | 28 | public static function new_MbsBlank_list(data:MbsIO):MbsList 29 | { 30 | return new MbsList(data, MBS_BLANK, new MbsBlank(data)); 31 | } 32 | 33 | override public function getMbsType():MbsType 34 | { 35 | return MBS_BLANK; 36 | } 37 | 38 | public function new(data:MbsIO) 39 | { 40 | super(data); 41 | } 42 | 43 | public function allocateNew():Void 44 | { 45 | setAddress(data.allocate(MBS_BLANK.getSize())); 46 | } 47 | 48 | public function getName():String 49 | { 50 | return data.readString(address + name.address); 51 | } 52 | 53 | public function setName(_val:String):Void 54 | { 55 | data.writeString(address + name.address, _val); 56 | } 57 | 58 | public function getType():String 59 | { 60 | return data.readString(address + type.address); 61 | } 62 | 63 | public function setType(_val:String):Void 64 | { 65 | data.writeString(address + type.address, _val); 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /com/stencyl/io/mbs/MbsMusic.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io.mbs; 2 | 3 | import com.stencyl.io.mbs.MbsResource; 4 | import mbs.core.ComposedType; 5 | import mbs.core.MbsField; 6 | import mbs.core.MbsType; 7 | import mbs.core.MbsTypes.*; 8 | import mbs.io.MbsIO; 9 | import mbs.io.MbsList; 10 | 11 | class MbsMusic extends MbsResource 12 | { 13 | public static var loop:MbsField; 14 | public static var pan:MbsField; 15 | public static var stream:MbsField; 16 | public static var type:MbsField; 17 | public static var volume:MbsField; 18 | 19 | public static var MBS_MUSIC:ComposedType; 20 | public static function initializeType():Void 21 | { 22 | if(MBS_MUSIC != null) return; 23 | MbsResource.initializeType(); 24 | 25 | MBS_MUSIC = new ComposedType("MbsMusic"); 26 | MBS_MUSIC.setInstantiator(function(data) return new MbsMusic(data)); 27 | MBS_MUSIC.inherit(MbsResource.MBS_RESOURCE); 28 | 29 | loop = MBS_MUSIC.createField("loop", BOOLEAN); 30 | pan = MBS_MUSIC.createField("pan", INTEGER); 31 | stream = MBS_MUSIC.createField("stream", BOOLEAN); 32 | type = MBS_MUSIC.createField("type", STRING); 33 | volume = MBS_MUSIC.createField("volume", INTEGER); 34 | 35 | } 36 | 37 | public static function new_MbsMusic_list(data:MbsIO):MbsList 38 | { 39 | return new MbsList(data, MBS_MUSIC, new MbsMusic(data)); 40 | } 41 | 42 | override public function getMbsType():MbsType 43 | { 44 | return MBS_MUSIC; 45 | } 46 | 47 | public function new(data:MbsIO) 48 | { 49 | super(data); 50 | } 51 | 52 | override public function allocateNew():Void 53 | { 54 | setAddress(data.allocate(MBS_MUSIC.getSize())); 55 | } 56 | 57 | public function getLoop():Bool 58 | { 59 | return data.readBool(address + loop.address); 60 | } 61 | 62 | public function setLoop(_val:Bool):Void 63 | { 64 | data.writeBool(address + loop.address, _val); 65 | } 66 | 67 | public function getPan():Int 68 | { 69 | return data.readInt(address + pan.address); 70 | } 71 | 72 | public function setPan(_val:Int):Void 73 | { 74 | data.writeInt(address + pan.address, _val); 75 | } 76 | 77 | public function getStream():Bool 78 | { 79 | return data.readBool(address + stream.address); 80 | } 81 | 82 | public function setStream(_val:Bool):Void 83 | { 84 | data.writeBool(address + stream.address, _val); 85 | } 86 | 87 | public function getType():String 88 | { 89 | return data.readString(address + type.address); 90 | } 91 | 92 | public function setType(_val:String):Void 93 | { 94 | data.writeString(address + type.address, _val); 95 | } 96 | 97 | public function getVolume():Int 98 | { 99 | return data.readInt(address + volume.address); 100 | } 101 | 102 | public function setVolume(_val:Int):Void 103 | { 104 | data.writeInt(address + volume.address, _val); 105 | } 106 | 107 | } 108 | -------------------------------------------------------------------------------- /com/stencyl/io/mbs/MbsResource.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io.mbs; 2 | 3 | import mbs.core.ComposedType; 4 | import mbs.core.MbsField; 5 | import mbs.core.MbsObject; 6 | import mbs.core.MbsType; 7 | import mbs.core.MbsTypes.*; 8 | import mbs.io.MbsIO; 9 | import mbs.io.MbsList; 10 | 11 | class MbsResource extends MbsObject 12 | { 13 | public static var atlasID:MbsField; 14 | public static var description:MbsField; 15 | public static var id:MbsField; 16 | public static var name:MbsField; 17 | 18 | public static var MBS_RESOURCE:ComposedType; 19 | public static function initializeType():Void 20 | { 21 | if(MBS_RESOURCE != null) return; 22 | MBS_RESOURCE = new ComposedType("MbsResource"); 23 | MBS_RESOURCE.setInstantiator(function(data) return new MbsResource(data)); 24 | 25 | atlasID = MBS_RESOURCE.createField("atlasID", INTEGER); 26 | description = MBS_RESOURCE.createField("description", STRING); 27 | id = MBS_RESOURCE.createField("id", INTEGER); 28 | name = MBS_RESOURCE.createField("name", STRING); 29 | 30 | } 31 | 32 | public static function new_MbsResource_list(data:MbsIO):MbsList 33 | { 34 | return new MbsList(data, MBS_RESOURCE, new MbsResource(data)); 35 | } 36 | 37 | override public function getMbsType():MbsType 38 | { 39 | return MBS_RESOURCE; 40 | } 41 | 42 | public function new(data:MbsIO) 43 | { 44 | super(data); 45 | } 46 | 47 | public function allocateNew():Void 48 | { 49 | setAddress(data.allocate(MBS_RESOURCE.getSize())); 50 | } 51 | 52 | public function getAtlasID():Int 53 | { 54 | return data.readInt(address + atlasID.address); 55 | } 56 | 57 | public function setAtlasID(_val:Int):Void 58 | { 59 | data.writeInt(address + atlasID.address, _val); 60 | } 61 | 62 | public function getDescription():String 63 | { 64 | return data.readString(address + description.address); 65 | } 66 | 67 | public function setDescription(_val:String):Void 68 | { 69 | data.writeString(address + description.address, _val); 70 | } 71 | 72 | public function getId():Int 73 | { 74 | return data.readInt(address + id.address); 75 | } 76 | 77 | public function setId(_val:Int):Void 78 | { 79 | data.writeInt(address + id.address, _val); 80 | } 81 | 82 | public function getName():String 83 | { 84 | return data.readString(address + name.address); 85 | } 86 | 87 | public function setName(_val:String):Void 88 | { 89 | data.writeString(address + name.address, _val); 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /com/stencyl/io/mbs/game/MbsAtlas.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io.mbs.game; 2 | 3 | import mbs.core.ComposedType; 4 | import mbs.core.MbsField; 5 | import mbs.core.MbsObject; 6 | import mbs.core.MbsType; 7 | import mbs.core.MbsTypes.*; 8 | import mbs.io.MbsIO; 9 | import mbs.io.MbsList; 10 | import mbs.io.MbsListBase.MbsIntList; 11 | 12 | class MbsAtlas extends MbsObject 13 | { 14 | public static var id:MbsField; 15 | public static var name:MbsField; 16 | public static var members:MbsField; 17 | public static var allScenes:MbsField; 18 | 19 | public static var MBS_ATLAS:ComposedType; 20 | public static function initializeType():Void 21 | { 22 | if(MBS_ATLAS != null) return; 23 | MBS_ATLAS = new ComposedType("MbsAtlas"); 24 | MBS_ATLAS.setInstantiator(function(data) return new MbsAtlas(data)); 25 | 26 | id = MBS_ATLAS.createField("id", INTEGER); 27 | name = MBS_ATLAS.createField("name", STRING); 28 | members = MBS_ATLAS.createField("members", LIST); 29 | allScenes = MBS_ATLAS.createField("allScenes", BOOLEAN); 30 | 31 | } 32 | 33 | public static function new_MbsAtlas_list(data:MbsIO):MbsList 34 | { 35 | return new MbsList(data, MBS_ATLAS, new MbsAtlas(data)); 36 | } 37 | 38 | override public function getMbsType():MbsType 39 | { 40 | return MBS_ATLAS; 41 | } 42 | 43 | private var _members:MbsIntList; 44 | 45 | public function new(data:MbsIO) 46 | { 47 | super(data); 48 | _members = new MbsIntList(data); 49 | } 50 | 51 | public function allocateNew():Void 52 | { 53 | setAddress(data.allocate(MBS_ATLAS.getSize())); 54 | } 55 | 56 | public function getId():Int 57 | { 58 | return data.readInt(address + id.address); 59 | } 60 | 61 | public function setId(_val:Int):Void 62 | { 63 | data.writeInt(address + id.address, _val); 64 | } 65 | 66 | public function getName():String 67 | { 68 | return data.readString(address + name.address); 69 | } 70 | 71 | public function setName(_val:String):Void 72 | { 73 | data.writeString(address + name.address, _val); 74 | } 75 | 76 | public function getMembers():MbsIntList 77 | { 78 | _members.setAddress(data.readInt(address + members.address)); 79 | return _members; 80 | } 81 | 82 | public function createMembers(_length:Int):MbsIntList 83 | { 84 | _members.allocateNew(_length); 85 | data.writeInt(address + members.address, _members.getAddress()); 86 | return _members; 87 | } 88 | 89 | public function getAllScenes():Bool 90 | { 91 | return data.readBool(address + allScenes.address); 92 | } 93 | 94 | public function setAllScenes(_val:Bool):Void 95 | { 96 | data.writeBool(address + allScenes.address, _val); 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /com/stencyl/io/mbs/game/MbsCollisionGroup.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io.mbs.game; 2 | 3 | import mbs.core.ComposedType; 4 | import mbs.core.MbsField; 5 | import mbs.core.MbsObject; 6 | import mbs.core.MbsType; 7 | import mbs.core.MbsTypes.*; 8 | import mbs.io.MbsIO; 9 | import mbs.io.MbsList; 10 | 11 | class MbsCollisionGroup extends MbsObject 12 | { 13 | public static var id:MbsField; 14 | public static var name:MbsField; 15 | 16 | public static var MBS_COLLISION_GROUP:ComposedType; 17 | public static function initializeType():Void 18 | { 19 | if(MBS_COLLISION_GROUP != null) return; 20 | MBS_COLLISION_GROUP = new ComposedType("MbsCollisionGroup"); 21 | MBS_COLLISION_GROUP.setInstantiator(function(data) return new MbsCollisionGroup(data)); 22 | 23 | id = MBS_COLLISION_GROUP.createField("id", INTEGER); 24 | name = MBS_COLLISION_GROUP.createField("name", STRING); 25 | 26 | } 27 | 28 | public static function new_MbsCollisionGroup_list(data:MbsIO):MbsList 29 | { 30 | return new MbsList(data, MBS_COLLISION_GROUP, new MbsCollisionGroup(data)); 31 | } 32 | 33 | override public function getMbsType():MbsType 34 | { 35 | return MBS_COLLISION_GROUP; 36 | } 37 | 38 | public function new(data:MbsIO) 39 | { 40 | super(data); 41 | } 42 | 43 | public function allocateNew():Void 44 | { 45 | setAddress(data.allocate(MBS_COLLISION_GROUP.getSize())); 46 | } 47 | 48 | public function getId():Int 49 | { 50 | return data.readInt(address + id.address); 51 | } 52 | 53 | public function setId(_val:Int):Void 54 | { 55 | data.writeInt(address + id.address, _val); 56 | } 57 | 58 | public function getName():String 59 | { 60 | return data.readString(address + name.address); 61 | } 62 | 63 | public function setName(_val:String):Void 64 | { 65 | data.writeString(address + name.address, _val); 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /com/stencyl/io/mbs/game/MbsCollisionPair.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io.mbs.game; 2 | 3 | import mbs.core.ComposedType; 4 | import mbs.core.MbsField; 5 | import mbs.core.MbsObject; 6 | import mbs.core.MbsType; 7 | import mbs.core.MbsTypes.*; 8 | import mbs.io.MbsIO; 9 | import mbs.io.MbsList; 10 | 11 | class MbsCollisionPair extends MbsObject 12 | { 13 | public static var group1:MbsField; 14 | public static var group2:MbsField; 15 | 16 | public static var MBS_COLLISION_PAIR:ComposedType; 17 | public static function initializeType():Void 18 | { 19 | if(MBS_COLLISION_PAIR != null) return; 20 | MBS_COLLISION_PAIR = new ComposedType("MbsCollisionPair"); 21 | MBS_COLLISION_PAIR.setInstantiator(function(data) return new MbsCollisionPair(data)); 22 | 23 | group1 = MBS_COLLISION_PAIR.createField("group1", INTEGER); 24 | group2 = MBS_COLLISION_PAIR.createField("group2", INTEGER); 25 | 26 | } 27 | 28 | public static function new_MbsCollisionPair_list(data:MbsIO):MbsList 29 | { 30 | return new MbsList(data, MBS_COLLISION_PAIR, new MbsCollisionPair(data)); 31 | } 32 | 33 | override public function getMbsType():MbsType 34 | { 35 | return MBS_COLLISION_PAIR; 36 | } 37 | 38 | public function new(data:MbsIO) 39 | { 40 | super(data); 41 | } 42 | 43 | public function allocateNew():Void 44 | { 45 | setAddress(data.allocate(MBS_COLLISION_PAIR.getSize())); 46 | } 47 | 48 | public function getGroup1():Int 49 | { 50 | return data.readInt(address + group1.address); 51 | } 52 | 53 | public function setGroup1(_val:Int):Void 54 | { 55 | data.writeInt(address + group1.address, _val); 56 | } 57 | 58 | public function getGroup2():Int 59 | { 60 | return data.readInt(address + group2.address); 61 | } 62 | 63 | public function setGroup2(_val:Int):Void 64 | { 65 | data.writeInt(address + group2.address, _val); 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /com/stencyl/io/mbs/game/MbsCollisionShape.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io.mbs.game; 2 | 3 | import com.stencyl.io.mbs.shape.MbsPoint; 4 | import mbs.core.ComposedType; 5 | import mbs.core.MbsField; 6 | import mbs.core.MbsObject; 7 | import mbs.core.MbsType; 8 | import mbs.core.MbsTypes.*; 9 | import mbs.io.MbsIO; 10 | import mbs.io.MbsList; 11 | 12 | class MbsCollisionShape extends MbsObject 13 | { 14 | public static var id:MbsField; 15 | public static var points:MbsField; 16 | 17 | public static var MBS_COLLISION_SHAPE:ComposedType; 18 | public static function initializeType():Void 19 | { 20 | if(MBS_COLLISION_SHAPE != null) return; 21 | MBS_COLLISION_SHAPE = new ComposedType("MbsCollisionShape"); 22 | MBS_COLLISION_SHAPE.setInstantiator(function(data) return new MbsCollisionShape(data)); 23 | 24 | id = MBS_COLLISION_SHAPE.createField("id", INTEGER); 25 | points = MBS_COLLISION_SHAPE.createField("points", LIST); 26 | 27 | } 28 | 29 | public static function new_MbsCollisionShape_list(data:MbsIO):MbsList 30 | { 31 | return new MbsList(data, MBS_COLLISION_SHAPE, new MbsCollisionShape(data)); 32 | } 33 | 34 | override public function getMbsType():MbsType 35 | { 36 | return MBS_COLLISION_SHAPE; 37 | } 38 | 39 | private var _points:MbsList; 40 | 41 | public function new(data:MbsIO) 42 | { 43 | super(data); 44 | _points = new MbsList(data, MbsPoint.MBS_POINT, new MbsPoint(data)); 45 | } 46 | 47 | public function allocateNew():Void 48 | { 49 | setAddress(data.allocate(MBS_COLLISION_SHAPE.getSize())); 50 | } 51 | 52 | public function getId():Int 53 | { 54 | return data.readInt(address + id.address); 55 | } 56 | 57 | public function setId(_val:Int):Void 58 | { 59 | data.writeInt(address + id.address, _val); 60 | } 61 | 62 | public function getPoints():MbsList 63 | { 64 | _points.setAddress(data.readInt(address + points.address)); 65 | return _points; 66 | } 67 | 68 | public function createPoints(_length:Int):MbsList 69 | { 70 | _points.allocateNew(_length); 71 | data.writeInt(address + points.address, _points.getAddress()); 72 | return _points; 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /com/stencyl/io/mbs/game/autotile/MbsCorners.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io.mbs.game.autotile; 2 | 3 | import com.stencyl.io.mbs.shape.MbsPoint; 4 | import mbs.core.ComposedType; 5 | import mbs.core.MbsField; 6 | import mbs.core.MbsObject; 7 | import mbs.core.MbsType; 8 | import mbs.io.MbsIO; 9 | import mbs.io.MbsList; 10 | 11 | class MbsCorners extends MbsObject 12 | { 13 | public static var topLeft:MbsField; 14 | public static var topRight:MbsField; 15 | public static var bottomLeft:MbsField; 16 | public static var bottomRight:MbsField; 17 | 18 | public static var MBS_CORNERS:ComposedType; 19 | public static function initializeType():Void 20 | { 21 | if(MBS_CORNERS != null) return; 22 | MBS_CORNERS = new ComposedType("MbsCorners"); 23 | MBS_CORNERS.setInstantiator(function(data) return new MbsCorners(data)); 24 | 25 | topLeft = MBS_CORNERS.createField("topLeft", MbsPoint.MBS_POINT); 26 | topRight = MBS_CORNERS.createField("topRight", MbsPoint.MBS_POINT); 27 | bottomLeft = MBS_CORNERS.createField("bottomLeft", MbsPoint.MBS_POINT); 28 | bottomRight = MBS_CORNERS.createField("bottomRight", MbsPoint.MBS_POINT); 29 | 30 | } 31 | 32 | public static function new_MbsCorners_list(data:MbsIO):MbsList 33 | { 34 | return new MbsList(data, MBS_CORNERS, new MbsCorners(data)); 35 | } 36 | 37 | override public function getMbsType():MbsType 38 | { 39 | return MBS_CORNERS; 40 | } 41 | 42 | private var _topLeft:MbsPoint; 43 | private var _topRight:MbsPoint; 44 | private var _bottomLeft:MbsPoint; 45 | private var _bottomRight:MbsPoint; 46 | 47 | public function new(data:MbsIO) 48 | { 49 | super(data); 50 | _topLeft = new MbsPoint(data); 51 | _topRight = new MbsPoint(data); 52 | _bottomLeft = new MbsPoint(data); 53 | _bottomRight = new MbsPoint(data); 54 | } 55 | 56 | public function allocateNew():Void 57 | { 58 | setAddress(data.allocate(MBS_CORNERS.getSize())); 59 | } 60 | 61 | public function getTopLeft():MbsPoint 62 | { 63 | _topLeft.setAddress(address + topLeft.address); 64 | return _topLeft; 65 | } 66 | 67 | public function getTopRight():MbsPoint 68 | { 69 | _topRight.setAddress(address + topRight.address); 70 | return _topRight; 71 | } 72 | 73 | public function getBottomLeft():MbsPoint 74 | { 75 | _bottomLeft.setAddress(address + bottomLeft.address); 76 | return _bottomLeft; 77 | } 78 | 79 | public function getBottomRight():MbsPoint 80 | { 81 | _bottomRight.setAddress(address + bottomRight.address); 82 | return _bottomRight; 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /com/stencyl/io/mbs/scene/MbsSceneHeader.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io.mbs.scene; 2 | 3 | import mbs.core.ComposedType; 4 | import mbs.core.MbsField; 5 | import mbs.core.MbsObject; 6 | import mbs.core.MbsType; 7 | import mbs.core.MbsTypes.*; 8 | import mbs.io.MbsIO; 9 | import mbs.io.MbsList; 10 | 11 | class MbsSceneHeader extends MbsObject 12 | { 13 | public static var id:MbsField; 14 | public static var name:MbsField; 15 | public static var description:MbsField; 16 | 17 | public static var MBS_SCENE_HEADER:ComposedType; 18 | public static function initializeType():Void 19 | { 20 | if(MBS_SCENE_HEADER != null) return; 21 | MBS_SCENE_HEADER = new ComposedType("MbsSceneHeader"); 22 | MBS_SCENE_HEADER.setInstantiator(function(data) return new MbsSceneHeader(data)); 23 | 24 | id = MBS_SCENE_HEADER.createField("id", INTEGER); 25 | name = MBS_SCENE_HEADER.createField("name", STRING); 26 | description = MBS_SCENE_HEADER.createField("description", STRING); 27 | 28 | } 29 | 30 | public static function new_MbsSceneHeader_list(data:MbsIO):MbsList 31 | { 32 | return new MbsList(data, MBS_SCENE_HEADER, new MbsSceneHeader(data)); 33 | } 34 | 35 | override public function getMbsType():MbsType 36 | { 37 | return MBS_SCENE_HEADER; 38 | } 39 | 40 | public function new(data:MbsIO) 41 | { 42 | super(data); 43 | } 44 | 45 | public function allocateNew():Void 46 | { 47 | setAddress(data.allocate(MBS_SCENE_HEADER.getSize())); 48 | } 49 | 50 | public function getId():Int 51 | { 52 | return data.readInt(address + id.address); 53 | } 54 | 55 | public function setId(_val:Int):Void 56 | { 57 | data.writeInt(address + id.address, _val); 58 | } 59 | 60 | public function getName():String 61 | { 62 | return data.readString(address + name.address); 63 | } 64 | 65 | public function setName(_val:String):Void 66 | { 67 | data.writeString(address + name.address, _val); 68 | } 69 | 70 | public function getDescription():String 71 | { 72 | return data.readString(address + description.address); 73 | } 74 | 75 | public function setDescription(_val:String):Void 76 | { 77 | data.writeString(address + description.address, _val); 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /com/stencyl/io/mbs/scene/layers/MbsColorBackground.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io.mbs.scene.layers; 2 | 3 | import mbs.core.ComposedType; 4 | import mbs.core.MbsField; 5 | import mbs.core.MbsObject; 6 | import mbs.core.MbsType; 7 | import mbs.core.MbsTypes.*; 8 | import mbs.io.MbsIO; 9 | import mbs.io.MbsList; 10 | 11 | class MbsColorBackground extends MbsObject 12 | { 13 | public static var color:MbsField; 14 | 15 | public static var MBS_COLOR_BACKGROUND:ComposedType; 16 | public static function initializeType():Void 17 | { 18 | if(MBS_COLOR_BACKGROUND != null) return; 19 | MBS_COLOR_BACKGROUND = new ComposedType("MbsColorBackground"); 20 | MBS_COLOR_BACKGROUND.setInstantiator(function(data) return new MbsColorBackground(data)); 21 | 22 | color = MBS_COLOR_BACKGROUND.createField("color", INTEGER); 23 | 24 | } 25 | 26 | public static function new_MbsColorBackground_list(data:MbsIO):MbsList 27 | { 28 | return new MbsList(data, MBS_COLOR_BACKGROUND, new MbsColorBackground(data)); 29 | } 30 | 31 | override public function getMbsType():MbsType 32 | { 33 | return MBS_COLOR_BACKGROUND; 34 | } 35 | 36 | public function new(data:MbsIO) 37 | { 38 | super(data); 39 | } 40 | 41 | public function allocateNew():Void 42 | { 43 | setAddress(data.allocate(MBS_COLOR_BACKGROUND.getSize())); 44 | } 45 | 46 | public function getColor():Int 47 | { 48 | return data.readInt(address + color.address); 49 | } 50 | 51 | public function setColor(_val:Int):Void 52 | { 53 | data.writeInt(address + color.address, _val); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /com/stencyl/io/mbs/scene/layers/MbsGradientBackground.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io.mbs.scene.layers; 2 | 3 | import mbs.core.ComposedType; 4 | import mbs.core.MbsField; 5 | import mbs.core.MbsObject; 6 | import mbs.core.MbsType; 7 | import mbs.core.MbsTypes.*; 8 | import mbs.io.MbsIO; 9 | import mbs.io.MbsList; 10 | 11 | class MbsGradientBackground extends MbsObject 12 | { 13 | public static var color1:MbsField; 14 | public static var color2:MbsField; 15 | 16 | public static var MBS_GRADIENT_BACKGROUND:ComposedType; 17 | public static function initializeType():Void 18 | { 19 | if(MBS_GRADIENT_BACKGROUND != null) return; 20 | MBS_GRADIENT_BACKGROUND = new ComposedType("MbsGradientBackground"); 21 | MBS_GRADIENT_BACKGROUND.setInstantiator(function(data) return new MbsGradientBackground(data)); 22 | 23 | color1 = MBS_GRADIENT_BACKGROUND.createField("color1", INTEGER); 24 | color2 = MBS_GRADIENT_BACKGROUND.createField("color2", INTEGER); 25 | 26 | } 27 | 28 | public static function new_MbsGradientBackground_list(data:MbsIO):MbsList 29 | { 30 | return new MbsList(data, MBS_GRADIENT_BACKGROUND, new MbsGradientBackground(data)); 31 | } 32 | 33 | override public function getMbsType():MbsType 34 | { 35 | return MBS_GRADIENT_BACKGROUND; 36 | } 37 | 38 | public function new(data:MbsIO) 39 | { 40 | super(data); 41 | } 42 | 43 | public function allocateNew():Void 44 | { 45 | setAddress(data.allocate(MBS_GRADIENT_BACKGROUND.getSize())); 46 | } 47 | 48 | public function getColor1():Int 49 | { 50 | return data.readInt(address + color1.address); 51 | } 52 | 53 | public function setColor1(_val:Int):Void 54 | { 55 | data.writeInt(address + color1.address, _val); 56 | } 57 | 58 | public function getColor2():Int 59 | { 60 | return data.readInt(address + color2.address); 61 | } 62 | 63 | public function setColor2(_val:Int):Void 64 | { 65 | data.writeInt(address + color2.address, _val); 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /com/stencyl/io/mbs/scene/layers/MbsImageBackground.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io.mbs.scene.layers; 2 | 3 | import com.stencyl.io.mbs.scene.layers.MbsLayer; 4 | import mbs.core.ComposedType; 5 | import mbs.core.MbsField; 6 | import mbs.core.MbsType; 7 | import mbs.core.MbsTypes.*; 8 | import mbs.io.MbsIO; 9 | import mbs.io.MbsList; 10 | 11 | class MbsImageBackground extends MbsLayer 12 | { 13 | public static var resourceID:MbsField; 14 | public static var customScroll:MbsField; 15 | 16 | public static var MBS_IMAGE_BACKGROUND:ComposedType; 17 | public static function initializeType():Void 18 | { 19 | if(MBS_IMAGE_BACKGROUND != null) return; 20 | MbsLayer.initializeType(); 21 | 22 | MBS_IMAGE_BACKGROUND = new ComposedType("MbsImageBackground"); 23 | MBS_IMAGE_BACKGROUND.setInstantiator(function(data) return new MbsImageBackground(data)); 24 | MBS_IMAGE_BACKGROUND.inherit(MbsLayer.MBS_LAYER); 25 | 26 | resourceID = MBS_IMAGE_BACKGROUND.createField("resourceID", INTEGER); 27 | customScroll = MBS_IMAGE_BACKGROUND.createField("customScroll", BOOLEAN); 28 | 29 | } 30 | 31 | public static function new_MbsImageBackground_list(data:MbsIO):MbsList 32 | { 33 | return new MbsList(data, MBS_IMAGE_BACKGROUND, new MbsImageBackground(data)); 34 | } 35 | 36 | override public function getMbsType():MbsType 37 | { 38 | return MBS_IMAGE_BACKGROUND; 39 | } 40 | 41 | public function new(data:MbsIO) 42 | { 43 | super(data); 44 | } 45 | 46 | override public function allocateNew():Void 47 | { 48 | setAddress(data.allocate(MBS_IMAGE_BACKGROUND.getSize())); 49 | } 50 | 51 | public function getResourceID():Int 52 | { 53 | return data.readInt(address + resourceID.address); 54 | } 55 | 56 | public function setResourceID(_val:Int):Void 57 | { 58 | data.writeInt(address + resourceID.address, _val); 59 | } 60 | 61 | public function getCustomScroll():Bool 62 | { 63 | return data.readBool(address + customScroll.address); 64 | } 65 | 66 | public function setCustomScroll(_val:Bool):Void 67 | { 68 | data.writeBool(address + customScroll.address, _val); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /com/stencyl/io/mbs/scene/layers/MbsInteractiveLayer.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io.mbs.scene.layers; 2 | 3 | import com.stencyl.io.mbs.scene.layers.MbsLayer; 4 | import mbs.core.ComposedType; 5 | import mbs.core.MbsField; 6 | import mbs.core.MbsType; 7 | import mbs.core.MbsTypes.*; 8 | import mbs.io.MbsIO; 9 | import mbs.io.MbsList; 10 | 11 | class MbsInteractiveLayer extends MbsLayer 12 | { 13 | public static var color:MbsField; 14 | 15 | public static var MBS_INTERACTIVE_LAYER:ComposedType; 16 | public static function initializeType():Void 17 | { 18 | if(MBS_INTERACTIVE_LAYER != null) return; 19 | MbsLayer.initializeType(); 20 | 21 | MBS_INTERACTIVE_LAYER = new ComposedType("MbsInteractiveLayer"); 22 | MBS_INTERACTIVE_LAYER.setInstantiator(function(data) return new MbsInteractiveLayer(data)); 23 | MBS_INTERACTIVE_LAYER.inherit(MbsLayer.MBS_LAYER); 24 | 25 | color = MBS_INTERACTIVE_LAYER.createField("color", INTEGER); 26 | 27 | } 28 | 29 | public static function new_MbsInteractiveLayer_list(data:MbsIO):MbsList 30 | { 31 | return new MbsList(data, MBS_INTERACTIVE_LAYER, new MbsInteractiveLayer(data)); 32 | } 33 | 34 | override public function getMbsType():MbsType 35 | { 36 | return MBS_INTERACTIVE_LAYER; 37 | } 38 | 39 | public function new(data:MbsIO) 40 | { 41 | super(data); 42 | } 43 | 44 | override public function allocateNew():Void 45 | { 46 | setAddress(data.allocate(MBS_INTERACTIVE_LAYER.getSize())); 47 | } 48 | 49 | public function getColor():Int 50 | { 51 | return data.readInt(address + color.address); 52 | } 53 | 54 | public function setColor(_val:Int):Void 55 | { 56 | data.writeInt(address + color.address, _val); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /com/stencyl/io/mbs/scene/physics/MbsJoint.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io.mbs.scene.physics; 2 | 3 | import mbs.core.ComposedType; 4 | import mbs.core.MbsField; 5 | import mbs.core.MbsObject; 6 | import mbs.core.MbsType; 7 | import mbs.core.MbsTypes.*; 8 | import mbs.io.MbsIO; 9 | import mbs.io.MbsList; 10 | 11 | class MbsJoint extends MbsObject 12 | { 13 | public static var id:MbsField; 14 | public static var name:MbsField; 15 | public static var actor1:MbsField; 16 | public static var actor2:MbsField; 17 | public static var collide:MbsField; 18 | 19 | public static var MBS_JOINT:ComposedType; 20 | public static function initializeType():Void 21 | { 22 | if(MBS_JOINT != null) return; 23 | MBS_JOINT = new ComposedType("MbsJoint"); 24 | MBS_JOINT.setInstantiator(function(data) return new MbsJoint(data)); 25 | 26 | id = MBS_JOINT.createField("id", INTEGER); 27 | name = MBS_JOINT.createField("name", STRING); 28 | actor1 = MBS_JOINT.createField("actor1", INTEGER); 29 | actor2 = MBS_JOINT.createField("actor2", INTEGER); 30 | collide = MBS_JOINT.createField("collide", BOOLEAN); 31 | 32 | } 33 | 34 | public static function new_MbsJoint_list(data:MbsIO):MbsList 35 | { 36 | return new MbsList(data, MBS_JOINT, new MbsJoint(data)); 37 | } 38 | 39 | override public function getMbsType():MbsType 40 | { 41 | return MBS_JOINT; 42 | } 43 | 44 | public function new(data:MbsIO) 45 | { 46 | super(data); 47 | } 48 | 49 | public function allocateNew():Void 50 | { 51 | setAddress(data.allocate(MBS_JOINT.getSize())); 52 | } 53 | 54 | public function getId():Int 55 | { 56 | return data.readInt(address + id.address); 57 | } 58 | 59 | public function setId(_val:Int):Void 60 | { 61 | data.writeInt(address + id.address, _val); 62 | } 63 | 64 | public function getName():String 65 | { 66 | return data.readString(address + name.address); 67 | } 68 | 69 | public function setName(_val:String):Void 70 | { 71 | data.writeString(address + name.address, _val); 72 | } 73 | 74 | public function getActor1():Int 75 | { 76 | return data.readInt(address + actor1.address); 77 | } 78 | 79 | public function setActor1(_val:Int):Void 80 | { 81 | data.writeInt(address + actor1.address, _val); 82 | } 83 | 84 | public function getActor2():Int 85 | { 86 | return data.readInt(address + actor2.address); 87 | } 88 | 89 | public function setActor2(_val:Int):Void 90 | { 91 | data.writeInt(address + actor2.address, _val); 92 | } 93 | 94 | public function getCollide():Bool 95 | { 96 | return data.readBool(address + collide.address); 97 | } 98 | 99 | public function setCollide(_val:Bool):Void 100 | { 101 | data.writeBool(address + collide.address, _val); 102 | } 103 | 104 | } 105 | -------------------------------------------------------------------------------- /com/stencyl/io/mbs/scene/physics/MbsStickJoint.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io.mbs.scene.physics; 2 | 3 | import com.stencyl.io.mbs.scene.physics.MbsJoint; 4 | import mbs.core.ComposedType; 5 | import mbs.core.MbsField; 6 | import mbs.core.MbsType; 7 | import mbs.core.MbsTypes.*; 8 | import mbs.io.MbsIO; 9 | import mbs.io.MbsList; 10 | 11 | class MbsStickJoint extends MbsJoint 12 | { 13 | public static var damping:MbsField; 14 | public static var frequency:MbsField; 15 | 16 | public static var MBS_STICK_JOINT:ComposedType; 17 | public static function initializeType():Void 18 | { 19 | if(MBS_STICK_JOINT != null) return; 20 | MbsJoint.initializeType(); 21 | 22 | MBS_STICK_JOINT = new ComposedType("MbsStickJoint"); 23 | MBS_STICK_JOINT.setInstantiator(function(data) return new MbsStickJoint(data)); 24 | MBS_STICK_JOINT.inherit(MbsJoint.MBS_JOINT); 25 | 26 | damping = MBS_STICK_JOINT.createField("damping", FLOAT); 27 | frequency = MBS_STICK_JOINT.createField("frequency", FLOAT); 28 | 29 | } 30 | 31 | public static function new_MbsStickJoint_list(data:MbsIO):MbsList 32 | { 33 | return new MbsList(data, MBS_STICK_JOINT, new MbsStickJoint(data)); 34 | } 35 | 36 | override public function getMbsType():MbsType 37 | { 38 | return MBS_STICK_JOINT; 39 | } 40 | 41 | public function new(data:MbsIO) 42 | { 43 | super(data); 44 | } 45 | 46 | override public function allocateNew():Void 47 | { 48 | setAddress(data.allocate(MBS_STICK_JOINT.getSize())); 49 | } 50 | 51 | public function getDamping():Float 52 | { 53 | return data.readFloat(address + damping.address); 54 | } 55 | 56 | public function setDamping(_val:Float):Void 57 | { 58 | data.writeFloat(address + damping.address, _val); 59 | } 60 | 61 | public function getFrequency():Float 62 | { 63 | return data.readFloat(address + frequency.address); 64 | } 65 | 66 | public function setFrequency(_val:Float):Void 67 | { 68 | data.writeFloat(address + frequency.address, _val); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /com/stencyl/io/mbs/scene/physics/MbsTerrainRegion.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io.mbs.scene.physics; 2 | 3 | import com.stencyl.io.mbs.scene.physics.MbsRegion; 4 | import mbs.core.ComposedType; 5 | import mbs.core.MbsField; 6 | import mbs.core.MbsType; 7 | import mbs.core.MbsTypes.*; 8 | import mbs.io.MbsIO; 9 | import mbs.io.MbsList; 10 | 11 | class MbsTerrainRegion extends MbsRegion 12 | { 13 | public static var groupID:MbsField; 14 | 15 | public static var MBS_TERRAIN_REGION:ComposedType; 16 | public static function initializeType():Void 17 | { 18 | if(MBS_TERRAIN_REGION != null) return; 19 | MbsRegion.initializeType(); 20 | 21 | MBS_TERRAIN_REGION = new ComposedType("MbsTerrainRegion"); 22 | MBS_TERRAIN_REGION.setInstantiator(function(data) return new MbsTerrainRegion(data)); 23 | MBS_TERRAIN_REGION.inherit(MbsRegion.MBS_REGION); 24 | 25 | groupID = MBS_TERRAIN_REGION.createField("groupID", INTEGER); 26 | 27 | } 28 | 29 | public static function new_MbsTerrainRegion_list(data:MbsIO):MbsList 30 | { 31 | return new MbsList(data, MBS_TERRAIN_REGION, new MbsTerrainRegion(data)); 32 | } 33 | 34 | override public function getMbsType():MbsType 35 | { 36 | return MBS_TERRAIN_REGION; 37 | } 38 | 39 | public function new(data:MbsIO) 40 | { 41 | super(data); 42 | } 43 | 44 | override public function allocateNew():Void 45 | { 46 | setAddress(data.allocate(MBS_TERRAIN_REGION.getSize())); 47 | } 48 | 49 | public function getGroupID():Int 50 | { 51 | return data.readInt(address + groupID.address); 52 | } 53 | 54 | public function setGroupID(_val:Int):Void 55 | { 56 | data.writeInt(address + groupID.address, _val); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /com/stencyl/io/mbs/shape/MbsCircle.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io.mbs.shape; 2 | 3 | import com.stencyl.io.mbs.shape.MbsShape; 4 | import mbs.core.ComposedType; 5 | import mbs.core.MbsField; 6 | import mbs.core.MbsType; 7 | import mbs.core.MbsTypes.*; 8 | import mbs.io.MbsIO; 9 | import mbs.io.MbsList; 10 | 11 | class MbsCircle extends MbsShape 12 | { 13 | public static var position:MbsField; 14 | public static var radius:MbsField; 15 | 16 | public static var MBS_CIRCLE:ComposedType; 17 | public static function initializeType():Void 18 | { 19 | if(MBS_CIRCLE != null) return; 20 | MbsShape.initializeType(); 21 | 22 | MBS_CIRCLE = new ComposedType("MbsCircle"); 23 | MBS_CIRCLE.setInstantiator(function(data) return new MbsCircle(data)); 24 | MBS_CIRCLE.inherit(MbsShape.MBS_SHAPE); 25 | 26 | position = MBS_CIRCLE.createField("position", MbsPoint.MBS_POINT); 27 | radius = MBS_CIRCLE.createField("radius", FLOAT); 28 | 29 | } 30 | 31 | public static function new_MbsCircle_list(data:MbsIO):MbsList 32 | { 33 | return new MbsList(data, MBS_CIRCLE, new MbsCircle(data)); 34 | } 35 | 36 | override public function getMbsType():MbsType 37 | { 38 | return MBS_CIRCLE; 39 | } 40 | 41 | private var _position:MbsPoint; 42 | 43 | public function new(data:MbsIO) 44 | { 45 | super(data); 46 | _position = new MbsPoint(data); 47 | } 48 | 49 | override public function allocateNew():Void 50 | { 51 | setAddress(data.allocate(MBS_CIRCLE.getSize())); 52 | } 53 | 54 | public function getPosition():MbsPoint 55 | { 56 | _position.setAddress(address + position.address); 57 | return _position; 58 | } 59 | 60 | public function getRadius():Float 61 | { 62 | return data.readFloat(address + radius.address); 63 | } 64 | 65 | public function setRadius(_val:Float):Void 66 | { 67 | data.writeFloat(address + radius.address, _val); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /com/stencyl/io/mbs/shape/MbsPoint.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io.mbs.shape; 2 | 3 | import mbs.core.ComposedType; 4 | import mbs.core.MbsField; 5 | import mbs.core.MbsObject; 6 | import mbs.core.MbsType; 7 | import mbs.core.MbsTypes.*; 8 | import mbs.io.MbsIO; 9 | import mbs.io.MbsList; 10 | 11 | class MbsPoint extends MbsObject 12 | { 13 | public static var x:MbsField; 14 | public static var y:MbsField; 15 | 16 | public static var MBS_POINT:ComposedType; 17 | public static function initializeType():Void 18 | { 19 | if(MBS_POINT != null) return; 20 | MBS_POINT = new ComposedType("MbsPoint"); 21 | MBS_POINT.setInstantiator(function(data) return new MbsPoint(data)); 22 | 23 | x = MBS_POINT.createField("x", FLOAT); 24 | y = MBS_POINT.createField("y", FLOAT); 25 | 26 | } 27 | 28 | public static function new_MbsPoint_list(data:MbsIO):MbsList 29 | { 30 | return new MbsList(data, MBS_POINT, new MbsPoint(data)); 31 | } 32 | 33 | override public function getMbsType():MbsType 34 | { 35 | return MBS_POINT; 36 | } 37 | 38 | public function new(data:MbsIO) 39 | { 40 | super(data); 41 | } 42 | 43 | public function allocateNew():Void 44 | { 45 | setAddress(data.allocate(MBS_POINT.getSize())); 46 | } 47 | 48 | public function getX():Float 49 | { 50 | return data.readFloat(address + x.address); 51 | } 52 | 53 | public function setX(_val:Float):Void 54 | { 55 | data.writeFloat(address + x.address, _val); 56 | } 57 | 58 | public function getY():Float 59 | { 60 | return data.readFloat(address + y.address); 61 | } 62 | 63 | public function setY(_val:Float):Void 64 | { 65 | data.writeFloat(address + y.address, _val); 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /com/stencyl/io/mbs/shape/MbsPolyRegion.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io.mbs.shape; 2 | 3 | import com.stencyl.io.mbs.shape.MbsPolygon; 4 | import mbs.core.ComposedType; 5 | import mbs.core.MbsField; 6 | import mbs.core.MbsType; 7 | import mbs.core.MbsTypes.*; 8 | import mbs.io.MbsIO; 9 | import mbs.io.MbsList; 10 | 11 | class MbsPolyRegion extends MbsPolygon 12 | { 13 | public static var width:MbsField; 14 | public static var height:MbsField; 15 | 16 | public static var MBS_POLY_REGION:ComposedType; 17 | public static function initializeType():Void 18 | { 19 | if(MBS_POLY_REGION != null) return; 20 | MbsPolygon.initializeType(); 21 | 22 | MBS_POLY_REGION = new ComposedType("MbsPolyRegion"); 23 | MBS_POLY_REGION.setInstantiator(function(data) return new MbsPolyRegion(data)); 24 | MBS_POLY_REGION.inherit(MbsPolygon.MBS_POLYGON); 25 | 26 | width = MBS_POLY_REGION.createField("width", INTEGER); 27 | height = MBS_POLY_REGION.createField("height", INTEGER); 28 | 29 | } 30 | 31 | public static function new_MbsPolyRegion_list(data:MbsIO):MbsList 32 | { 33 | return new MbsList(data, MBS_POLY_REGION, new MbsPolyRegion(data)); 34 | } 35 | 36 | override public function getMbsType():MbsType 37 | { 38 | return MBS_POLY_REGION; 39 | } 40 | 41 | public function new(data:MbsIO) 42 | { 43 | super(data); 44 | } 45 | 46 | override public function allocateNew():Void 47 | { 48 | setAddress(data.allocate(MBS_POLY_REGION.getSize())); 49 | } 50 | 51 | public function getWidth():Int 52 | { 53 | return data.readInt(address + width.address); 54 | } 55 | 56 | public function setWidth(_val:Int):Void 57 | { 58 | data.writeInt(address + width.address, _val); 59 | } 60 | 61 | public function getHeight():Int 62 | { 63 | return data.readInt(address + height.address); 64 | } 65 | 66 | public function setHeight(_val:Int):Void 67 | { 68 | data.writeInt(address + height.address, _val); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /com/stencyl/io/mbs/shape/MbsPolygon.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io.mbs.shape; 2 | 3 | import com.stencyl.io.mbs.shape.MbsPoint; 4 | import com.stencyl.io.mbs.shape.MbsShape; 5 | import mbs.core.ComposedType; 6 | import mbs.core.MbsField; 7 | import mbs.core.MbsType; 8 | import mbs.core.MbsTypes.*; 9 | import mbs.io.MbsIO; 10 | import mbs.io.MbsList; 11 | 12 | class MbsPolygon extends MbsShape 13 | { 14 | public static var points:MbsField; 15 | 16 | public static var MBS_POLYGON:ComposedType; 17 | public static function initializeType():Void 18 | { 19 | if(MBS_POLYGON != null) return; 20 | MbsShape.initializeType(); 21 | 22 | MBS_POLYGON = new ComposedType("MbsPolygon"); 23 | MBS_POLYGON.setInstantiator(function(data) return new MbsPolygon(data)); 24 | MBS_POLYGON.inherit(MbsShape.MBS_SHAPE); 25 | 26 | points = MBS_POLYGON.createField("points", LIST); 27 | 28 | } 29 | 30 | public static function new_MbsPolygon_list(data:MbsIO):MbsList 31 | { 32 | return new MbsList(data, MBS_POLYGON, new MbsPolygon(data)); 33 | } 34 | 35 | override public function getMbsType():MbsType 36 | { 37 | return MBS_POLYGON; 38 | } 39 | 40 | private var _points:MbsList; 41 | 42 | public function new(data:MbsIO) 43 | { 44 | super(data); 45 | _points = new MbsList(data, MbsPoint.MBS_POINT, new MbsPoint(data)); 46 | } 47 | 48 | override public function allocateNew():Void 49 | { 50 | setAddress(data.allocate(MBS_POLYGON.getSize())); 51 | } 52 | 53 | public function getPoints():MbsList 54 | { 55 | _points.setAddress(data.readInt(address + points.address)); 56 | return _points; 57 | } 58 | 59 | public function createPoints(_length:Int):MbsList 60 | { 61 | _points.allocateNew(_length); 62 | data.writeInt(address + points.address, _points.getAddress()); 63 | return _points; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /com/stencyl/io/mbs/shape/MbsShape.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io.mbs.shape; 2 | 3 | import mbs.core.ComposedType; 4 | import mbs.core.MbsObject; 5 | import mbs.core.MbsType; 6 | import mbs.io.MbsIO; 7 | import mbs.io.MbsList; 8 | 9 | class MbsShape extends MbsObject 10 | { 11 | 12 | public static var MBS_SHAPE:ComposedType; 13 | public static function initializeType():Void 14 | { 15 | if(MBS_SHAPE != null) return; 16 | MBS_SHAPE = new ComposedType("MbsShape"); 17 | MBS_SHAPE.setInstantiator(function(data) return new MbsShape(data)); 18 | 19 | } 20 | 21 | public static function new_MbsShape_list(data:MbsIO):MbsList 22 | { 23 | return new MbsList(data, MBS_SHAPE, new MbsShape(data)); 24 | } 25 | 26 | override public function getMbsType():MbsType 27 | { 28 | return MBS_SHAPE; 29 | } 30 | 31 | public function new(data:MbsIO) 32 | { 33 | super(data); 34 | } 35 | 36 | public function allocateNew():Void 37 | { 38 | setAddress(data.allocate(MBS_SHAPE.getSize())); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /com/stencyl/io/mbs/shape/MbsWireframe.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io.mbs.shape; 2 | 3 | import com.stencyl.io.mbs.shape.MbsPolygon; 4 | import mbs.core.ComposedType; 5 | import mbs.core.MbsField; 6 | import mbs.core.MbsType; 7 | import mbs.io.MbsIO; 8 | import mbs.io.MbsList; 9 | 10 | class MbsWireframe extends MbsPolygon 11 | { 12 | public static var position:MbsField; 13 | 14 | public static var MBS_WIREFRAME:ComposedType; 15 | public static function initializeType():Void 16 | { 17 | if(MBS_WIREFRAME != null) return; 18 | MbsPolygon.initializeType(); 19 | 20 | MBS_WIREFRAME = new ComposedType("MbsWireframe"); 21 | MBS_WIREFRAME.setInstantiator(function(data) return new MbsWireframe(data)); 22 | MBS_WIREFRAME.inherit(MbsPolygon.MBS_POLYGON); 23 | 24 | position = MBS_WIREFRAME.createField("position", MbsPoint.MBS_POINT); 25 | 26 | } 27 | 28 | public static function new_MbsWireframe_list(data:MbsIO):MbsList 29 | { 30 | return new MbsList(data, MBS_WIREFRAME, new MbsWireframe(data)); 31 | } 32 | 33 | override public function getMbsType():MbsType 34 | { 35 | return MBS_WIREFRAME; 36 | } 37 | 38 | private var _position:MbsPoint; 39 | 40 | public function new(data:MbsIO) 41 | { 42 | super(data); 43 | _position = new MbsPoint(data); 44 | } 45 | 46 | override public function allocateNew():Void 47 | { 48 | setAddress(data.allocate(MBS_WIREFRAME.getSize())); 49 | } 50 | 51 | public function getPosition():MbsPoint 52 | { 53 | _position.setAddress(address + position.address); 54 | return _position; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /com/stencyl/io/mbs/snippet/MbsAttribute.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io.mbs.snippet; 2 | 3 | import mbs.core.ComposedType; 4 | import mbs.core.MbsField; 5 | import mbs.core.MbsObject; 6 | import mbs.core.MbsType; 7 | import mbs.core.MbsTypes.*; 8 | import mbs.io.MbsDynamicHelper; 9 | import mbs.io.MbsIO; 10 | import mbs.io.MbsList; 11 | 12 | class MbsAttribute extends MbsObject 13 | { 14 | public static var id:MbsField; 15 | public static var type:MbsField; 16 | public static var value:MbsField; 17 | 18 | public static var MBS_ATTRIBUTE:ComposedType; 19 | public static function initializeType():Void 20 | { 21 | if(MBS_ATTRIBUTE != null) return; 22 | MBS_ATTRIBUTE = new ComposedType("MbsAttribute"); 23 | MBS_ATTRIBUTE.setInstantiator(function(data) return new MbsAttribute(data)); 24 | 25 | id = MBS_ATTRIBUTE.createField("id", INTEGER); 26 | type = MBS_ATTRIBUTE.createField("type", STRING); 27 | value = MBS_ATTRIBUTE.createField("value", DYNAMIC); 28 | 29 | } 30 | 31 | public static function new_MbsAttribute_list(data:MbsIO):MbsList 32 | { 33 | return new MbsList(data, MBS_ATTRIBUTE, new MbsAttribute(data)); 34 | } 35 | 36 | override public function getMbsType():MbsType 37 | { 38 | return MBS_ATTRIBUTE; 39 | } 40 | 41 | public function new(data:MbsIO) 42 | { 43 | super(data); 44 | } 45 | 46 | public function allocateNew():Void 47 | { 48 | setAddress(data.allocate(MBS_ATTRIBUTE.getSize())); 49 | } 50 | 51 | public function getId():Int 52 | { 53 | return data.readInt(address + id.address); 54 | } 55 | 56 | public function setId(_val:Int):Void 57 | { 58 | data.writeInt(address + id.address, _val); 59 | } 60 | 61 | public function getType():String 62 | { 63 | return data.readString(address + type.address); 64 | } 65 | 66 | public function setType(_val:String):Void 67 | { 68 | data.writeString(address + type.address, _val); 69 | } 70 | 71 | public function getValue():Dynamic 72 | { 73 | return MbsDynamicHelper.readDynamic(data, address + value.address); 74 | } 75 | 76 | public function setValue(_val:Dynamic):Void 77 | { 78 | MbsDynamicHelper.writeDynamic(data, address + value.address, _val); 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /com/stencyl/io/mbs/snippet/MbsBlock.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io.mbs.snippet; 2 | 3 | import mbs.core.ComposedType; 4 | import mbs.core.MbsField; 5 | import mbs.core.MbsObject; 6 | import mbs.core.MbsType; 7 | import mbs.core.MbsTypes.*; 8 | import mbs.io.MbsIO; 9 | import mbs.io.MbsList; 10 | 11 | class MbsBlock extends MbsObject 12 | { 13 | public static var type:MbsField; 14 | public static var id:MbsField; 15 | public static var blockID:MbsField; 16 | 17 | public static var MBS_BLOCK:ComposedType; 18 | public static function initializeType():Void 19 | { 20 | if(MBS_BLOCK != null) return; 21 | MBS_BLOCK = new ComposedType("MbsBlock"); 22 | MBS_BLOCK.setInstantiator(function(data) return new MbsBlock(data)); 23 | 24 | type = MBS_BLOCK.createField("type", STRING); 25 | id = MBS_BLOCK.createField("id", INTEGER); 26 | blockID = MBS_BLOCK.createField("blockID", INTEGER); 27 | 28 | } 29 | 30 | public static function new_MbsBlock_list(data:MbsIO):MbsList 31 | { 32 | return new MbsList(data, MBS_BLOCK, new MbsBlock(data)); 33 | } 34 | 35 | override public function getMbsType():MbsType 36 | { 37 | return MBS_BLOCK; 38 | } 39 | 40 | public function new(data:MbsIO) 41 | { 42 | super(data); 43 | } 44 | 45 | public function allocateNew():Void 46 | { 47 | setAddress(data.allocate(MBS_BLOCK.getSize())); 48 | } 49 | 50 | public function getType():String 51 | { 52 | return data.readString(address + type.address); 53 | } 54 | 55 | public function setType(_val:String):Void 56 | { 57 | data.writeString(address + type.address, _val); 58 | } 59 | 60 | public function getId():Int 61 | { 62 | return data.readInt(address + id.address); 63 | } 64 | 65 | public function setId(_val:Int):Void 66 | { 67 | data.writeInt(address + id.address, _val); 68 | } 69 | 70 | public function getBlockID():Int 71 | { 72 | return data.readInt(address + blockID.address); 73 | } 74 | 75 | public function setBlockID(_val:Int):Void 76 | { 77 | data.writeInt(address + blockID.address, _val); 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /com/stencyl/io/mbs/snippet/MbsMapElement.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io.mbs.snippet; 2 | 3 | import mbs.core.ComposedType; 4 | import mbs.core.MbsField; 5 | import mbs.core.MbsObject; 6 | import mbs.core.MbsType; 7 | import mbs.core.MbsTypes.*; 8 | import mbs.io.MbsDynamicHelper; 9 | import mbs.io.MbsIO; 10 | import mbs.io.MbsList; 11 | 12 | class MbsMapElement extends MbsObject 13 | { 14 | public static var key:MbsField; 15 | public static var value:MbsField; 16 | 17 | public static var MBS_MAP_ELEMENT:ComposedType; 18 | public static function initializeType():Void 19 | { 20 | if(MBS_MAP_ELEMENT != null) return; 21 | MBS_MAP_ELEMENT = new ComposedType("MbsMapElement"); 22 | MBS_MAP_ELEMENT.setInstantiator(function(data) return new MbsMapElement(data)); 23 | 24 | key = MBS_MAP_ELEMENT.createField("key", STRING); 25 | value = MBS_MAP_ELEMENT.createField("value", DYNAMIC); 26 | 27 | } 28 | 29 | public static function new_MbsMapElement_list(data:MbsIO):MbsList 30 | { 31 | return new MbsList(data, MBS_MAP_ELEMENT, new MbsMapElement(data)); 32 | } 33 | 34 | override public function getMbsType():MbsType 35 | { 36 | return MBS_MAP_ELEMENT; 37 | } 38 | 39 | public function new(data:MbsIO) 40 | { 41 | super(data); 42 | } 43 | 44 | public function allocateNew():Void 45 | { 46 | setAddress(data.allocate(MBS_MAP_ELEMENT.getSize())); 47 | } 48 | 49 | public function getKey():String 50 | { 51 | return data.readString(address + key.address); 52 | } 53 | 54 | public function setKey(_val:String):Void 55 | { 56 | data.writeString(address + key.address, _val); 57 | } 58 | 59 | public function getValue():Dynamic 60 | { 61 | return MbsDynamicHelper.readDynamic(data, address + value.address); 62 | } 63 | 64 | public function setValue(_val:Dynamic):Void 65 | { 66 | MbsDynamicHelper.writeDynamic(data, address + value.address, _val); 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /com/stencyl/io/mbs/snippet/MbsSnippet.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.io.mbs.snippet; 2 | 3 | import com.stencyl.io.mbs.snippet.MbsAttribute; 4 | import mbs.core.ComposedType; 5 | import mbs.core.MbsField; 6 | import mbs.core.MbsObject; 7 | import mbs.core.MbsType; 8 | import mbs.core.MbsTypes.*; 9 | import mbs.io.MbsIO; 10 | import mbs.io.MbsList; 11 | 12 | class MbsSnippet extends MbsObject 13 | { 14 | public static var enabled:MbsField; 15 | public static var id:MbsField; 16 | public static var properties:MbsField; 17 | 18 | public static var MBS_SNIPPET:ComposedType; 19 | public static function initializeType():Void 20 | { 21 | if(MBS_SNIPPET != null) return; 22 | MBS_SNIPPET = new ComposedType("MbsSnippet"); 23 | MBS_SNIPPET.setInstantiator(function(data) return new MbsSnippet(data)); 24 | 25 | enabled = MBS_SNIPPET.createField("enabled", BOOLEAN); 26 | id = MBS_SNIPPET.createField("id", INTEGER); 27 | properties = MBS_SNIPPET.createField("properties", LIST); 28 | 29 | } 30 | 31 | public static function new_MbsSnippet_list(data:MbsIO):MbsList 32 | { 33 | return new MbsList(data, MBS_SNIPPET, new MbsSnippet(data)); 34 | } 35 | 36 | override public function getMbsType():MbsType 37 | { 38 | return MBS_SNIPPET; 39 | } 40 | 41 | private var _properties:MbsList; 42 | 43 | public function new(data:MbsIO) 44 | { 45 | super(data); 46 | _properties = new MbsList(data, MbsAttribute.MBS_ATTRIBUTE, new MbsAttribute(data)); 47 | } 48 | 49 | public function allocateNew():Void 50 | { 51 | setAddress(data.allocate(MBS_SNIPPET.getSize())); 52 | } 53 | 54 | public function getEnabled():Bool 55 | { 56 | return data.readBool(address + enabled.address); 57 | } 58 | 59 | public function setEnabled(_val:Bool):Void 60 | { 61 | data.writeBool(address + enabled.address, _val); 62 | } 63 | 64 | public function getId():Int 65 | { 66 | return data.readInt(address + id.address); 67 | } 68 | 69 | public function setId(_val:Int):Void 70 | { 71 | data.writeInt(address + id.address, _val); 72 | } 73 | 74 | public function getProperties():MbsList 75 | { 76 | _properties.setAddress(data.readInt(address + properties.address)); 77 | return _properties; 78 | } 79 | 80 | public function createProperties(_length:Int):MbsList 81 | { 82 | _properties.allocateNew(_length); 83 | data.writeInt(address + properties.address, _properties.getAddress()); 84 | return _properties; 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /com/stencyl/loader/CustomSwfPreloader.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.loader; 2 | 3 | #if flash 4 | 5 | import com.stencyl.utils.Utils; 6 | import openfl.display.Loader; 7 | import openfl.events.Event; 8 | import openfl.events.MouseEvent; 9 | import openfl.text.TextField; 10 | 11 | class CustomSwfPreloader extends StencylPreloader 12 | { 13 | private var clickArea:TextField; 14 | private var loader:Loader; 15 | 16 | public function new() 17 | { 18 | super(); 19 | } 20 | 21 | public override function showPreloader() 22 | { 23 | adStarted(); 24 | 25 | var data = Utils.getConfigBytes(Config.swfPreloader.swfLoc); 26 | loader = new Loader(); 27 | var arr = data.getData(); 28 | loader.loadBytes(arr); 29 | loader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoaded); 30 | addChild(loader); 31 | 32 | clickArea = new TextField(); 33 | clickArea.selectable = false; 34 | clickArea.x = 0; 35 | clickArea.y = 0; 36 | clickArea.width = getWidth(); 37 | clickArea.height = getHeight(); 38 | 39 | addChild(clickArea); 40 | 41 | clickArea.addEventListener(MouseEvent.CLICK, startGame); 42 | } 43 | 44 | private function swfLoaded(event:Event) 45 | { 46 | var config = Config.swfPreloader; 47 | 48 | loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, swfLoaded); 49 | 50 | loader.content.width = config.swfWidth; 51 | loader.content.height = config.swfHeight; 52 | 53 | loader.content.scaleX = 1; 54 | loader.content.scaleY = 1; 55 | 56 | loader.content.x = config.swfX; 57 | loader.content.y = config.swfY; 58 | } 59 | 60 | private function startGame(event:Event) 61 | { 62 | clickArea.removeEventListener(MouseEvent.CLICK, startGame); 63 | removeChild(clickArea); 64 | 65 | adFinished(); 66 | } 67 | } 68 | 69 | #end -------------------------------------------------------------------------------- /com/stencyl/loader/PreloaderConfig.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.loader; 2 | 3 | #if(flash || html5) 4 | class PreloaderConfig 5 | { 6 | public function new() 7 | { 8 | 9 | } 10 | 11 | public function setFields(data:Dynamic) 12 | { 13 | authorURL = data.authorURL; 14 | backgroundColor = data.backgroundColor; 15 | backgroundImage = data.backgroundImage; 16 | badgeImage = data.badgeImage; 17 | borderThickness = data.borderThickness; 18 | borderColor = data.borderColor; 19 | barLocation = data.barLocation; 20 | barWidth = data.barWidth; 21 | barHeight = data.barHeight; 22 | barColor = data.barColor; 23 | barOffsetX = data.barOffsetX; 24 | barOffsetY = data.barOffsetY; 25 | barBackgroundColor = data.barBackgroundColor; 26 | } 27 | 28 | public var authorURL:String; 29 | 30 | public var backgroundColor:Int; 31 | public var backgroundImage:String; 32 | public var badgeImage:String; 33 | 34 | public var borderThickness:Int; 35 | public var borderColor:Int; 36 | public var barLocation:Int; 37 | public var barWidth:Int; 38 | public var barHeight:Int; 39 | public var barColor:Int; 40 | public var barOffsetX:Int; 41 | public var barOffsetY:Int; 42 | public var barBackgroundColor:Int; 43 | } 44 | #end -------------------------------------------------------------------------------- /com/stencyl/loader/SplashBox.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.loader; 2 | 3 | import com.stencyl.utils.motion.*; 4 | import com.stencyl.Engine; 5 | import openfl.text.*; 6 | 7 | #if stencyldemo 8 | 9 | class SplashBox 10 | { 11 | public function new() 12 | { 13 | var label:TextField = new TextField(); 14 | var fnt:TextFormat = new TextFormat("Arial", 12); 15 | fnt.color = 0xFFFFFF; 16 | 17 | label.defaultTextFormat = fnt; 18 | label.text = "Stencyl - Trial Mode"; 19 | label.background = true; 20 | label.backgroundColor = 0x333333; 21 | label.x = 0; 22 | label.y = 0; 23 | label.width = 120; 24 | label.height = 20; 25 | 26 | TweenManager.timer(100).doOnComplete(function() { 27 | Engine.engine.root.addChild(label); 28 | }); 29 | } 30 | } 31 | 32 | #end -------------------------------------------------------------------------------- /com/stencyl/loader/SwfPreloaderConfig.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.loader; 2 | 3 | #if flash 4 | class SwfPreloaderConfig 5 | { 6 | public function new() 7 | { 8 | 9 | } 10 | 11 | public function setFields(data:Dynamic) 12 | { 13 | swfLoc = data.swfLoc; 14 | swfX = data.swfX; 15 | swfY = data.swfY; 16 | swfWidth = data.swfWidth; 17 | swfHeight = data.swfHeight; 18 | } 19 | 20 | public var swfLoc:String; 21 | public var swfX:Int; 22 | public var swfY:Int; 23 | public var swfWidth:Int; 24 | public var swfHeight:Int; 25 | } 26 | #end -------------------------------------------------------------------------------- /com/stencyl/models/Atlas.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.models; 2 | 3 | class Atlas 4 | { 5 | public var ID:Int; 6 | public var name:String; 7 | public var allScenes:Bool; 8 | public var active:Bool; 9 | public var members:Array; 10 | 11 | public function new(ID:Int, name:String, allScenes:Bool, members:Array) 12 | { 13 | this.ID = ID; 14 | this.name = name; 15 | this.allScenes = allScenes; 16 | this.members = members; 17 | 18 | #if (cpp || hl) 19 | active = allScenes; 20 | #else 21 | active = true; 22 | #end 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /com/stencyl/models/Background.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.models; 2 | 3 | import openfl.display.Graphics; 4 | 5 | interface Background 6 | { 7 | function update():Void; 8 | function draw(g:Graphics, cameraX:Int, cameraY:Int, screenWidth:Int, screenHeight:Int):Void; 9 | } 10 | -------------------------------------------------------------------------------- /com/stencyl/models/CollisionGroupDef.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.models; 2 | 3 | class CollisionGroupDef 4 | { 5 | public var group1:Int; 6 | public var group2:Int; 7 | 8 | public function new(group1:Int, group2:Int) 9 | { 10 | this.group1 = group1; 11 | this.group2 = group2; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /com/stencyl/models/GroupDef.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.models; 2 | 3 | class GroupDef 4 | { 5 | public var ID:Int; 6 | public var name:String; 7 | 8 | public function new(ID:Int, name:String) 9 | { 10 | this.ID = ID; 11 | this.name = name; 12 | } 13 | } -------------------------------------------------------------------------------- /com/stencyl/models/Joystick.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.models; 2 | 3 | #if com.stencyl.joystick 4 | 5 | typedef Joystick = com.stencyl.joystick.Joystick; 6 | 7 | #end -------------------------------------------------------------------------------- /com/stencyl/models/PhysicsMode.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.models; 2 | 3 | @:enum abstract PhysicsMode(Int) from Int to Int 4 | { 5 | public var NORMAL_PHYSICS = 0; 6 | public var SIMPLE_PHYSICS = 1; 7 | public var MINIMAL_PHYSICS = 2; 8 | 9 | public function new(value:Int) this = value; 10 | 11 | @:from public static function fromInt (value:Int):PhysicsMode 12 | { 13 | return new PhysicsMode(value); 14 | } 15 | 16 | @:from public static function fromString (value:String):PhysicsMode 17 | { 18 | return switch (value) 19 | { 20 | case "NORMAL_PHYSICS": NORMAL_PHYSICS; 21 | case "SIMPLE_PHYSICS": SIMPLE_PHYSICS; 22 | case "MINIMAL_PHYSICS": MINIMAL_PHYSICS; 23 | default: NORMAL_PHYSICS; 24 | } 25 | } 26 | 27 | @:to public function toString ():String 28 | { 29 | return switch (this) 30 | { 31 | case NORMAL_PHYSICS: "NORMAL_PHYSICS"; 32 | case SIMPLE_PHYSICS: "SIMPLE_PHYSICS"; 33 | case MINIMAL_PHYSICS: "MINIMAL_PHYSICS"; 34 | default: "NORMAL_PHYSICS"; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /com/stencyl/models/Resource.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.models; 2 | 3 | import com.stencyl.Data; 4 | 5 | class Resource 6 | { 7 | public var ID:Int; 8 | public var atlasID:Int; 9 | public var name:String; 10 | public var sID:String; 11 | 12 | public function new(ID:Int, name:String, atlasID:Int) 13 | { 14 | this.ID = ID; 15 | this.atlasID = atlasID; 16 | this.name = name; 17 | 18 | sID = ID + "," + name; 19 | } 20 | 21 | public function toString():String 22 | { 23 | return sID; 24 | } 25 | 26 | //For Atlases 27 | 28 | public function isAtlasActive():Bool 29 | { 30 | var atlas = GameModel.get().atlases.get(atlasID); 31 | 32 | if(atlas == null) 33 | { 34 | return false; 35 | } 36 | 37 | return atlas.active; 38 | } 39 | 40 | public function loadGraphics() 41 | { 42 | } 43 | 44 | public function unloadGraphics() 45 | { 46 | } 47 | 48 | public function reloadGraphics(subID:Int) 49 | { 50 | unloadGraphics(); 51 | loadGraphics(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /com/stencyl/models/actor/ActorTweenProperties.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.models.actor; 2 | 3 | import com.stencyl.utils.motion.*; 4 | 5 | class ActorTweenProperties 6 | { 7 | public var xy:TweenFloat2; 8 | public var angle:TweenFloat; 9 | public var alpha:TweenFloat; 10 | public var realScaleXY:TweenFloat2; 11 | 12 | public function new() 13 | { 14 | xy = new TweenFloat2(); 15 | angle = new TweenFloat(); 16 | alpha = new TweenFloat(); 17 | realScaleXY = new TweenFloat2(); 18 | } 19 | 20 | public function pause() 21 | { 22 | xy.paused = true; 23 | angle.paused = true; 24 | alpha.paused = true; 25 | realScaleXY.paused = true; 26 | } 27 | 28 | public function unpause() 29 | { 30 | xy.paused = false; 31 | angle.paused = false; 32 | alpha.paused = false; 33 | realScaleXY.paused = false; 34 | } 35 | 36 | public function cancel() 37 | { 38 | if(xy.active) 39 | TweenManager.cancel(xy); 40 | if(angle.active) 41 | TweenManager.cancel(angle); 42 | if(alpha.active) 43 | TweenManager.cancel(alpha); 44 | if(realScaleXY.active) 45 | TweenManager.cancel(realScaleXY); 46 | } 47 | } -------------------------------------------------------------------------------- /com/stencyl/models/actor/ActorType.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.models.actor; 2 | 3 | import com.stencyl.behavior.BehaviorInstance; 4 | import com.stencyl.models.PhysicsMode; 5 | import com.stencyl.models.Resource; 6 | 7 | import box2D.dynamics.B2BodyDef; 8 | 9 | class ActorType extends Resource 10 | { 11 | public var groupID:Int; 12 | public var spriteID:Int; 13 | public var behaviorValues:Map; 14 | public var bodyDef:B2BodyDef; 15 | public var physicsMode:PhysicsMode; 16 | public var autoScale:Bool; 17 | public var pausable:Bool; 18 | public var ignoreGravity:Bool; 19 | 20 | public function new 21 | ( 22 | ID:Int, 23 | atlasID:Int, 24 | name:String, 25 | groupID:Int, 26 | spriteID:Int, 27 | behaviorValues:Map, 28 | bodyDef:B2BodyDef, 29 | physicsMode:PhysicsMode, 30 | autoScale:Bool, 31 | pausable:Bool, 32 | ignoreGravity:Bool 33 | ) 34 | { 35 | super(ID, name, atlasID); 36 | 37 | this.groupID = groupID; 38 | this.spriteID = spriteID; 39 | this.behaviorValues = behaviorValues; 40 | this.bodyDef = bodyDef; 41 | this.physicsMode = physicsMode; 42 | this.autoScale = autoScale; 43 | this.pausable = pausable; 44 | this.ignoreGravity = ignoreGravity; 45 | } 46 | 47 | override public function toString():String 48 | { 49 | return name; 50 | } 51 | 52 | //For Atlases 53 | 54 | override public function loadGraphics() 55 | { 56 | com.stencyl.Data.get().resources.get(spriteID).loadGraphics(); 57 | } 58 | 59 | override public function unloadGraphics() 60 | { 61 | com.stencyl.Data.get().resources.get(spriteID).unloadGraphics(); 62 | } 63 | } -------------------------------------------------------------------------------- /com/stencyl/models/actor/AngleHolder.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.models.actor; 2 | 3 | class AngleHolder 4 | { 5 | public var angle:Float; 6 | 7 | public function new() 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /com/stencyl/models/actor/CollisionPoint.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.models.actor; 2 | 3 | import com.stencyl.models.Actor; 4 | 5 | import box2D.common.math.B2Vec2; 6 | import box2D.dynamics.B2Fixture; 7 | 8 | class CollisionPoint 9 | { 10 | public var x:Float; 11 | public var y:Float; 12 | public var normalX:Float; 13 | public var normalY:Float; 14 | 15 | public function new(x:Float, y:Float, normalX:Float, normalY:Float) 16 | { 17 | this.x = x; 18 | this.y = y; 19 | this.normalX = normalX; 20 | this.normalY = normalY; 21 | } 22 | 23 | private static var freedCollisionPoints = new Array(); 24 | 25 | public static function resetStatics() 26 | { 27 | freedCollisionPoints = new Array(); 28 | } 29 | 30 | public static function get(x:Float, y:Float, normalX:Float, normalY:Float) 31 | { 32 | if(freedCollisionPoints.length > 0) 33 | { 34 | var cp = freedCollisionPoints.pop(); 35 | cp.x = x; 36 | cp.y = y; 37 | cp.normalX = normalX; 38 | cp.normalY = normalY; 39 | return cp; 40 | } 41 | else 42 | { 43 | return new CollisionPoint(x, y, normalX, normalY); 44 | } 45 | } 46 | 47 | public static function free(cp:CollisionPoint) 48 | { 49 | freedCollisionPoints.push(cp); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /com/stencyl/models/actor/Group.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.models.actor; 2 | 3 | class Group 4 | { 5 | public var list:Array; 6 | public var name:String; 7 | public var ID:Int; 8 | public var sID:String; 9 | 10 | public function new(ID:Int, name:String) 11 | { 12 | this.name = name; 13 | this.ID = ID; 14 | 15 | sID = "[Group " + ID + "," + name + "]"; 16 | 17 | list = new Array(); 18 | } 19 | 20 | public function addChild(a:Actor) 21 | { 22 | list.push(a); 23 | } 24 | 25 | public function removeChild(a:Actor) 26 | { 27 | 28 | } 29 | 30 | public function toString():String 31 | { 32 | return sID; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /com/stencyl/models/actor/Sprite.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.models.actor; 2 | 3 | import com.stencyl.models.Resource; 4 | 5 | class Sprite extends Resource 6 | { 7 | public var defaultAnimation:Int; 8 | public var animations:Map; 9 | public var readableImages:Bool; 10 | 11 | @:deprecated("Get width from individual animations") public var width(get, never):Int; 12 | @:deprecated("Get height from individual animations") public var height(get, never):Int; 13 | 14 | public function new(ID:Int, atlasID:Int, name:String, defaultAnimation:Int, readableImages:Bool) 15 | { 16 | super(ID, name, atlasID); 17 | 18 | this.defaultAnimation = defaultAnimation; 19 | this.readableImages = readableImages; 20 | 21 | animations = new Map(); 22 | } 23 | 24 | //For Atlases 25 | 26 | override public function loadGraphics() 27 | { 28 | for(a in animations.iterator()) 29 | { 30 | a.loadGraphics(); 31 | } 32 | } 33 | 34 | override public function unloadGraphics() 35 | { 36 | for(a in animations) 37 | { 38 | a.unloadGraphics(); 39 | } 40 | } 41 | 42 | override public function reloadGraphics(subID:Int) 43 | { 44 | if(subID == -1) 45 | { 46 | unloadGraphics(); 47 | loadGraphics(); 48 | } 49 | else 50 | { 51 | animations.get(subID).unloadGraphics(); 52 | animations.get(subID).loadGraphics(); 53 | } 54 | 55 | for(actor in Engine.engine.allActors) 56 | { 57 | if(actor != null && !actor.dead && !actor.recycled) 58 | { 59 | if(actor.type.spriteID == ID) 60 | { 61 | actor.reloadAnimationGraphics(subID); 62 | } 63 | } 64 | } 65 | } 66 | 67 | private function get_width():Int 68 | { 69 | var defaultAnim = animations.get(defaultAnimation); 70 | return Std.int(defaultAnim.imgWidth / defaultAnim.framesAcross); 71 | } 72 | 73 | private function get_height():Int 74 | { 75 | var defaultAnim = animations.get(defaultAnimation); 76 | return Std.int(defaultAnim.imgHeight / defaultAnim.framesDown); 77 | } 78 | } -------------------------------------------------------------------------------- /com/stencyl/models/background/ColorBackground.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.models.background; 2 | 3 | import openfl.display.Graphics; 4 | 5 | class ColorBackground extends Resource implements Background 6 | { 7 | public var bgColor:Int; 8 | 9 | public static var WHITE:Int = -1; 10 | public static var TRANSPARENT:Int = -2; 11 | 12 | public function new(bgColor:Int) 13 | { 14 | super(0, "Color Background", -1); 15 | 16 | this.bgColor = bgColor; 17 | 18 | //XXX: White gets turned into transparent?! 19 | //Ref: http://community.stencyl.com/index.php/topic,14480.0.html 20 | if(bgColor == WHITE) 21 | { 22 | this.bgColor = 0xffffff; 23 | } 24 | } 25 | 26 | public function update() 27 | { 28 | } 29 | 30 | public function draw(g:Graphics, cameraX:Int, cameraY:Int, screenWidth:Int, screenHeight:Int) 31 | { 32 | if(bgColor != TRANSPARENT) 33 | { 34 | g.clear(); 35 | g.beginFill(bgColor); 36 | g.drawRect(0, 0, screenWidth, screenHeight); 37 | g.endFill(); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /com/stencyl/models/background/GradientBackground.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.models.background; 2 | 3 | import openfl.display.BitmapData; 4 | import openfl.display.Graphics; 5 | import openfl.geom.Matrix; 6 | import openfl.display.GradientType; 7 | import openfl.display.SpreadMethod; 8 | 9 | class GradientBackground extends Resource implements Background 10 | { 11 | private var topColor:UInt; 12 | private var bottomColor:UInt; 13 | 14 | public function new(topColor:UInt, bottomColor:UInt) 15 | { 16 | super(0, "Gradient Background", -1); 17 | 18 | this.topColor = topColor; 19 | this.bottomColor = bottomColor; 20 | } 21 | 22 | public function update() 23 | { 24 | } 25 | 26 | public function draw(g:Graphics, cameraX:Int, cameraY:Int, screenWidth:Int, screenHeight:Int) 27 | { 28 | var colors = [topColor, bottomColor]; 29 | var alphas = [100., 100.]; 30 | var ratios = [0, 0xFF]; 31 | var matr = new Matrix(); 32 | matr.createGradientBox(screenWidth, screenHeight, Math.PI/2, 0, 0); 33 | var sprMethod = SpreadMethod.PAD; 34 | 35 | g.clear(); 36 | 37 | // Hack to avoid gradient center being shifted from other bitmap fills (text/image drawing) 38 | var tempImg = new BitmapData(1, 1); 39 | g.beginBitmapFill(tempImg); 40 | g.endFill(); 41 | 42 | g.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, matr, sprMethod); 43 | g.drawRect(0, 0, screenWidth, screenHeight); 44 | g.endFill(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /com/stencyl/models/background/ImageBackground.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.models.background; 2 | 3 | import openfl.display.Graphics; 4 | import openfl.display.BitmapData; 5 | 6 | import com.stencyl.Engine; 7 | import com.stencyl.models.scene.layers.BackgroundLayer; 8 | import com.stencyl.utils.Assets; 9 | 10 | class ImageBackground extends Resource implements Background 11 | { 12 | public var frames:Array; 13 | public var durations:Array; 14 | 15 | public var parallaxX:Float; 16 | public var parallaxY:Float; 17 | 18 | public var repeats:Bool; 19 | 20 | public var graphicsLoaded:Bool; 21 | 22 | public function new 23 | ( 24 | ID:Int, 25 | atlasID:Int, 26 | name:String, 27 | durations:Array, 28 | parallaxX:Float, 29 | parallaxY:Float, 30 | repeats:Bool 31 | ) 32 | { 33 | super(ID, name, atlasID); 34 | 35 | this.parallaxX = parallaxX; 36 | this.parallaxY = parallaxY; 37 | this.durations = durations; 38 | this.repeats = repeats; 39 | 40 | if(isAtlasActive()) 41 | { 42 | loadGraphics(); 43 | } 44 | } 45 | 46 | public function update() 47 | { 48 | } 49 | 50 | public function draw(g:Graphics, cameraX:Int, cameraY:Int, screenWidth:Int, screenHeight:Int) 51 | { 52 | } 53 | 54 | //For Atlases 55 | 56 | override public function loadGraphics() 57 | { 58 | if(graphicsLoaded) 59 | return; 60 | 61 | this.frames = new Array(); 62 | var numFrames = durations.length; 63 | 64 | if(numFrames > 0) 65 | { 66 | for(i in 0...numFrames) 67 | { 68 | frames.push 69 | ( 70 | Assets.getBitmapData 71 | ( 72 | "assets/graphics/" + Engine.IMG_BASE + "/background-" + ID + "-" + i + ".png", 73 | false 74 | ) 75 | ); 76 | } 77 | } 78 | 79 | else 80 | { 81 | frames.push 82 | ( 83 | Assets.getBitmapData 84 | ( 85 | "assets/graphics/" + Engine.IMG_BASE + "/background-" + ID + "-0.png", 86 | false 87 | ) 88 | ); 89 | } 90 | 91 | //--- 92 | 93 | graphicsLoaded = true; 94 | } 95 | 96 | override public function unloadGraphics() 97 | { 98 | if(!graphicsLoaded) 99 | return; 100 | 101 | //Replace with a 1x1 px blank - graceful fallback 102 | var img = new BitmapData(1, 1); 103 | frames = [for(d in durations) img]; 104 | 105 | //--- 106 | 107 | var numFrames = durations.length; 108 | 109 | graphicsLoaded = false; 110 | } 111 | 112 | override public function reloadGraphics(subID:Int) 113 | { 114 | super.reloadGraphics(subID); 115 | for(layer in Engine.engine.backgroundLayers) 116 | { 117 | if(layer.model == this) 118 | { 119 | layer.reload(layer.resourceID); 120 | } 121 | } 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /com/stencyl/models/background/ScrollingBackground.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.models.background; 2 | 3 | import openfl.display.Graphics; 4 | import openfl.display.BitmapData; 5 | 6 | class ScrollingBackground extends ImageBackground implements Background 7 | { 8 | public var xVelocity:Float; 9 | public var yVelocity:Float; 10 | 11 | public function new 12 | ( 13 | ID:Int, 14 | atlasID:Int, 15 | name:String, 16 | durations:Array, 17 | parallaxX:Float, 18 | parallaxY:Float, 19 | repeats:Bool, 20 | xVelocity:Float, 21 | yVelocity:Float 22 | ) 23 | { 24 | super(ID, atlasID, name, durations, parallaxX, parallaxY, repeats); 25 | 26 | this.xVelocity = xVelocity; 27 | this.yVelocity = yVelocity; 28 | } 29 | 30 | override public function update() 31 | { 32 | } 33 | 34 | override public function draw(g:Graphics, cameraX:Int, cameraY:Int, screenWidth:Int, screenHeight:Int) 35 | { 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /com/stencyl/models/collision/CollisionInfo.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.models.collision; 2 | 3 | class CollisionInfo 4 | { 5 | private static var infoArray:Array = new Array(); 6 | 7 | public static function resetStatics():Void 8 | { 9 | infoArray = new Array(); 10 | } 11 | 12 | public var max:Float; 13 | public var min:Float; 14 | 15 | public var maskA:Mask; 16 | public var maskB:Mask; 17 | 18 | public var solidCollision:Bool; 19 | 20 | public function new():Void 21 | { 22 | reset(); 23 | } 24 | 25 | public function reset():Void 26 | { 27 | max = min = 0; 28 | maskA = maskB = null; 29 | solidCollision = true; 30 | } 31 | 32 | public static function getCollisionInfo():CollisionInfo 33 | { 34 | if (infoArray.length > 0) 35 | { 36 | return infoArray.pop(); 37 | } 38 | 39 | return new CollisionInfo(); 40 | } 41 | 42 | public static function recycle(info:CollisionInfo):Void 43 | { 44 | infoArray.push(info); 45 | } 46 | } -------------------------------------------------------------------------------- /com/stencyl/models/scene/ActorInstance.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.models.scene; 2 | 3 | import com.stencyl.behavior.BehaviorInstance; 4 | import com.stencyl.models.actor.ActorType; 5 | import com.stencyl.models.Resource; 6 | 7 | class ActorInstance 8 | { 9 | public var elementID:Int; 10 | public var x:Int; 11 | public var y:Int; 12 | public var scaleX:Float; 13 | public var scaleY:Float; 14 | public var layerID:Int; 15 | public var orderInLayer:Int; 16 | public var angle:Int; 17 | public var groupID:Int; 18 | public var actorID:Int; 19 | public var isCustomized:Bool; 20 | public var behaviorValues:Map; 21 | 22 | public var actorType:ActorType; 23 | 24 | public function new 25 | ( 26 | elementID:Int, 27 | x:Int, 28 | y:Int, 29 | scaleX:Float, 30 | scaleY:Float, 31 | layerID:Int, 32 | orderInLayer:Int, 33 | angle:Int, 34 | groupID:Int, 35 | actorID:Int, 36 | behaviors:Map, 37 | isCustomized:Bool 38 | ) 39 | { 40 | this.elementID = elementID; 41 | this.x = x; 42 | this.y = y; 43 | this.scaleX = scaleX; 44 | this.scaleY = scaleY; 45 | this.layerID = layerID; 46 | this.orderInLayer = orderInLayer; 47 | this.angle = angle; 48 | this.groupID = groupID; 49 | 50 | this.actorID = actorID; 51 | this.behaviorValues = behaviors; 52 | this.isCustomized = isCustomized; 53 | 54 | this.actorType = cast(Data.get().resources.get(actorID), ActorType); 55 | 56 | //behaviorValues can be null, signifying to use the default ActorType config. 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /com/stencyl/models/scene/ActorLayer.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.models.scene; 2 | 3 | #if use_actor_tilemap 4 | typedef ActorLayer = openfl.display.Tilemap; 5 | #else 6 | typedef ActorLayer = openfl.display.Sprite; 7 | #end -------------------------------------------------------------------------------- /com/stencyl/models/scene/AutotileFormat.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.models.scene; 2 | 3 | //import haxe.ds.HashMap; 4 | import openfl.geom.Point; 5 | 6 | class AutotileFormat 7 | { 8 | public var autotileArrayLength:Int; 9 | public var defaultAnimationIndex:Int = 0; 10 | 11 | public var name:String; 12 | public var id:Int; 13 | 14 | public var tilesAcross:Int; 15 | public var tilesDown:Int; 16 | 17 | /** Maps full 0-255 autotile flag to its index in an array of animations / CornerSets. */ 18 | public var animIndex:Array = []; 19 | 20 | /** Maps animation index to the set of corners needed for that animation. */ 21 | public var animCorners:Array; 22 | 23 | public function new(name:String, id:Int, tilesAcross:Int, tilesDown:Int, corners:Array) 24 | { 25 | this.name = name; 26 | this.id = id; 27 | this.tilesAcross = tilesAcross; 28 | this.tilesDown = tilesDown; 29 | 30 | var arrayIndex = 0; 31 | 32 | //Can't use Haxe's HashMap because it only works with hashCode and not equality. 33 | //HashCode collisions cause this to break. 34 | var cornerIndices = new Map(); 35 | 36 | for(i in 0x00...0xFF + 1) 37 | { 38 | if(cornerIndices.exists(corners[i])) 39 | { 40 | animIndex[i] = cornerIndices.get(corners[i]); 41 | continue; 42 | } 43 | 44 | animIndex[i] = arrayIndex; 45 | cornerIndices.set(corners[i], arrayIndex); 46 | ++arrayIndex; 47 | } 48 | 49 | defaultAnimationIndex = animIndex[0xFF]; 50 | autotileArrayLength = arrayIndex; 51 | 52 | animCorners = []; 53 | for(i in 0x00...0xFF + 1) 54 | { 55 | animCorners[animIndex[i]] = corners[i]; 56 | } 57 | } 58 | } 59 | 60 | class Corners 61 | { 62 | public function new(tl:Point, tr:Point, bl:Point, br:Point) 63 | { 64 | this.tl = tl; 65 | this.tr = tr; 66 | this.bl = bl; 67 | this.br = br; 68 | } 69 | 70 | public var tl:Point; 71 | public var tr:Point; 72 | public var bl:Point; 73 | public var br:Point; 74 | 75 | /* 76 | public function hashCode():Int 77 | { 78 | var result = 7; 79 | result = 17 * result + pointHash(tl); 80 | result = 17 * result + pointHash(tr); 81 | result = 17 * result + pointHash(bl); 82 | result = 17 * result + pointHash(br); 83 | return result; 84 | } 85 | 86 | private function pointHash(p:Point):Int 87 | { 88 | var result = 17; 89 | result = 37 * result + Std.int(p.x); 90 | result = 37 * result + Std.int(p.y); 91 | return result; 92 | } 93 | */ 94 | 95 | public function toString():String 96 | { 97 | return 'TL: $tl, TR: $tr, BL: $bl, BR: $br'; 98 | } 99 | } -------------------------------------------------------------------------------- /com/stencyl/models/scene/DeferredActor.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.models.scene; 2 | 3 | import com.stencyl.models.actor.ActorType; 4 | 5 | class DeferredActor 6 | { 7 | public var type:ActorType; 8 | 9 | public var x:Float; 10 | public var y:Float; 11 | 12 | //Script.FRONT/MIDDLE/BACK 13 | public var layer:Int; 14 | 15 | public function new(type:ActorType, x:Float, y:Float, layer:Int) 16 | { 17 | this.type = type; 18 | this.x = x; 19 | this.y = y; 20 | this.layer = layer; 21 | } 22 | } -------------------------------------------------------------------------------- /com/stencyl/models/scene/DrawingLayer.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.models.scene; 2 | 3 | import com.stencyl.Config; 4 | import com.stencyl.graphics.G; 5 | import com.stencyl.utils.Utils; 6 | 7 | import openfl.display.Graphics; 8 | import openfl.display.Shape; 9 | import openfl.display.Sprite; 10 | #if use_actor_tilemap 11 | import openfl.display.Tilemap; 12 | #end 13 | 14 | class DrawingLayer extends #if use_actor_tilemap Tilemap #else Sprite #end 15 | { 16 | #if (use_actor_tilemap) 17 | //only used with Config.drawToLayers 18 | //if use_actor_tilemap is not enabled, these are naturally present as members of Sprite 19 | public var shape:Shape; 20 | public var graphics:Graphics; 21 | #end 22 | 23 | public function new(width:Int, height:Int) 24 | { 25 | super(#if use_actor_tilemap width, height, null, Config.antialias #end); 26 | 27 | #if (use_actor_tilemap) 28 | if(Config.drawToLayers) 29 | { 30 | shape = new Shape(); 31 | graphics = shape.graphics; 32 | } 33 | #end 34 | } 35 | 36 | public function clearFrame():Void 37 | { 38 | #if use_actor_tilemap 39 | Utils.removeAllTiles(this); 40 | #else 41 | Utils.removeAllChildren(this); 42 | #end 43 | 44 | if(Config.drawToLayers) 45 | { 46 | graphics.clear(); 47 | } 48 | } 49 | 50 | public function renderFrame(g:G):Void 51 | { 52 | #if use_actor_tilemap 53 | if(Config.drawToLayers) 54 | { 55 | g.layer = this; 56 | g.drawShape(graphics); 57 | } 58 | #end 59 | } 60 | } -------------------------------------------------------------------------------- /com/stencyl/models/scene/RegionDef.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.models.scene; 2 | 3 | import box2D.collision.shapes.B2Shape; 4 | import openfl.geom.Rectangle; 5 | 6 | class RegionDef 7 | { 8 | public var x:Float; 9 | public var y:Float; 10 | public var shape:B2Shape; 11 | public var shapes:Array; 12 | 13 | public var ID:Int; 14 | public var name:String; 15 | public var shapeID:Int; 16 | public var simpleBounds:Rectangle; 17 | 18 | public function new(shapes:Array, ID:Int, name:String, x:Float, y:Float, shapeID:Int=0, simpleBounds:Rectangle = null) 19 | { 20 | this.x = x; 21 | this.y = y; 22 | 23 | this.shapes = shapes; 24 | this.shape = this.shapes[0]; 25 | this.ID = ID; 26 | this.name = name; 27 | this.shapeID = shapeID; 28 | this.simpleBounds = simpleBounds; 29 | } 30 | } -------------------------------------------------------------------------------- /com/stencyl/models/scene/TerrainDef.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.models.scene; 2 | 3 | import box2D.collision.shapes.B2Shape; 4 | import com.stencyl.utils.Utils; 5 | 6 | class TerrainDef 7 | { 8 | public var x:Float; 9 | public var y:Float; 10 | public var shape:B2Shape; 11 | public var shapes:Array; 12 | 13 | public var ID:Int; 14 | public var name:String; 15 | public var groupID:Int; 16 | public var fillColor:Int; 17 | 18 | public function new(shapes:Array, ID:Int, name:String, x:Float, y:Float, groupID:Int=0, fillColor:Int=0) 19 | { 20 | this.x = x; 21 | this.y = y; 22 | 23 | this.shapes = shapes; 24 | this.shape = this.shapes[0]; 25 | this.ID = ID; 26 | this.name = name; 27 | this.groupID = groupID; 28 | 29 | if(this.fillColor == 0) 30 | { 31 | this.fillColor = Utils.getColorRGB(0, 0, 0); 32 | } 33 | 34 | this.fillColor = fillColor; 35 | } 36 | } -------------------------------------------------------------------------------- /com/stencyl/models/scene/Wireframe.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.models.scene; 2 | 3 | import box2D.collision.shapes.B2Shape; 4 | import com.stencyl.models.collision.Mask; 5 | 6 | class Wireframe 7 | { 8 | public var x:Float; 9 | public var y:Float; 10 | 11 | public var shape:Dynamic; //Usually an array of B2PolygonShapes 12 | public var shape2:Mask; 13 | 14 | public var width:Float; 15 | public var height:Float; 16 | 17 | public function new(x:Float, y:Float, width:Float, height:Float, shape:Dynamic, shape2:Mask) 18 | { 19 | this.x = x; 20 | this.y = y; 21 | this.width = width; 22 | this.height = height; 23 | this.shape = shape; 24 | this.shape2 = shape2; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /com/stencyl/models/scene/layers/RegularLayer.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.models.scene.layers; 2 | 3 | import openfl.display.BlendMode; 4 | import openfl.display.Sprite; 5 | 6 | import com.stencyl.utils.motion.*; 7 | 8 | class RegularLayer extends Sprite 9 | { 10 | public var ID:Int; 11 | public var layerName:String; 12 | public var order:Int; 13 | public var scrollFactorX:Float; 14 | public var scrollFactorY:Float; 15 | public var opacity:Float; 16 | 17 | public var alphaTween:TweenFloat; 18 | 19 | public function new(ID:Int, name:String, order:Int, scrollFactorX:Float, scrollFactorY:Float, opacity:Float, blendMode:BlendMode) 20 | { 21 | super(); 22 | this.ID = ID; 23 | this.name = name; 24 | this.layerName = name; 25 | this.order = order; 26 | this.scrollFactorX = scrollFactorX; 27 | this.scrollFactorY = scrollFactorY; 28 | alpha = opacity; 29 | this.blendMode = blendMode; 30 | } 31 | 32 | public function updatePosition(x:Float, y:Float, elapsedTime:Float) 33 | { 34 | 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /com/stencyl/utils/ConfigUtil.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.utils; 2 | 3 | import haxe.xml.Access; 4 | 5 | class ConfigUtil 6 | { 7 | public static function xmlToMap(xml:Access, keyProperty:String, valueProperty:String):Map 8 | { 9 | var map:Map = []; 10 | 11 | for(e in xml.elements) 12 | { 13 | map.set(e.x.get(keyProperty), e.x.get(valueProperty)); 14 | } 15 | 16 | return map; 17 | } 18 | 19 | public static inline function readString(map:Map, propertyName:String):String 20 | { 21 | return map.get(propertyName); 22 | } 23 | 24 | public static inline function readInt(map:Map, propertyName:String):Int 25 | { 26 | return Std.parseInt(map.get(propertyName)); 27 | } 28 | 29 | public static inline function readFloat(map:Map, propertyName:String):Float 30 | { 31 | return Std.parseFloat(map.get(propertyName)); 32 | } 33 | 34 | public static inline function readBool(map:Map, propertyName:String):Bool 35 | { 36 | return map.get(propertyName) == "true"; 37 | } 38 | } -------------------------------------------------------------------------------- /com/stencyl/utils/HaxeDefines.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.utils; 2 | 3 | class HaxeDefines 4 | { 5 | macro public static function getDefines():haxe.macro.Expr 6 | { 7 | var defines : Map = haxe.macro.Context.getDefines(); 8 | // Construct map syntax so we can return it as an expression 9 | var map : Array = []; 10 | for (key in defines.keys()) 11 | { 12 | map.push(macro $v{key} => $v{Std.string(defines.get(key))}); 13 | } 14 | return macro $a{map}; 15 | } 16 | } -------------------------------------------------------------------------------- /com/stencyl/utils/HscriptRunner.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.utils; 2 | 3 | #if (stencyltools && !(scriptable || cppia)) 4 | 5 | import hscript.*; 6 | 7 | class HscriptRunner 8 | { 9 | var parser:Parser; 10 | var interp:Interp; 11 | 12 | public function new() 13 | { 14 | parser = new Parser(); 15 | interp = new Interp(); 16 | 17 | interp.variables.set("trace", Reflect.makeVarArgs(function(el) { 18 | var inf = interp.posInfos(); 19 | inf.className = "Script"; 20 | inf.methodName = "run"; 21 | var v = el.shift(); 22 | if( el.length > 0 ) inf.customParams = el; 23 | haxe.Log.trace(v, inf); 24 | })); 25 | } 26 | 27 | public function registerVar(name:String, obj:Dynamic):Void 28 | { 29 | interp.variables.set(name, obj); 30 | } 31 | 32 | public function execute(script:String) 33 | { 34 | var program = parser.parseString(script); 35 | interp.execute(program); 36 | } 37 | } 38 | 39 | #end -------------------------------------------------------------------------------- /com/stencyl/utils/LazyIntMap.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.utils; 2 | 3 | #if macro 4 | import haxe.macro.Context; 5 | import haxe.macro.Expr; 6 | import haxe.macro.Type; 7 | 8 | using haxe.macro.TypeTools; 9 | #end 10 | 11 | class LazyIntMap 12 | { 13 | macro public static function fromFunction(e:Expr) 14 | { 15 | var type = Context.typeof(e); 16 | var keyType:Type = null; 17 | var valueType:Type = null; 18 | 19 | switch(type) 20 | { 21 | case TFun(args, ret): 22 | if(args.length == 1) 23 | { 24 | keyType = args[0].t; 25 | valueType = ret; 26 | } 27 | case(_): 28 | } 29 | 30 | var key = keyType.toComplexType(); 31 | var value = valueType.toComplexType(); 32 | 33 | return macro new LazyIntMap<$value>(new Map(), $e); 34 | } 35 | 36 | private var map:Map; 37 | private var initializer:Int->V; 38 | 39 | public function new(map:Map, initializer:Int->V) 40 | { 41 | this.map = map; 42 | this.initializer = initializer; 43 | } 44 | 45 | public function get(key:Int):V 46 | { 47 | var obj:V = map.get(key); 48 | 49 | if(obj == null) 50 | { 51 | obj = initializer(key); 52 | map.set(key, obj); 53 | } 54 | 55 | return obj; 56 | } 57 | 58 | public inline function set(key:Int, value:V) map.set(key, value); 59 | public inline function exists(key:Int) return map.exists(key); 60 | public inline function remove(key:Int) return map.remove(key); 61 | public inline function keys():Iterator return map.keys(); 62 | public inline function iterator():Iterator return map.iterator(); 63 | } -------------------------------------------------------------------------------- /com/stencyl/utils/LazyMap.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.utils; 2 | 3 | #if macro 4 | import haxe.macro.Context; 5 | import haxe.macro.Expr; 6 | import haxe.macro.Type; 7 | 8 | using haxe.macro.TypeTools; 9 | #end 10 | 11 | class LazyMap 12 | { 13 | macro public static function fromFunction(e:Expr) 14 | { 15 | var type = Context.typeof(e); 16 | var keyType:Type = null; 17 | var valueType:Type = null; 18 | 19 | switch(type) 20 | { 21 | case TFun(args, ret): 22 | if(args.length == 1) 23 | { 24 | keyType = args[0].t; 25 | valueType = ret; 26 | } 27 | case(_): 28 | } 29 | 30 | var key = keyType.toComplexType(); 31 | var value = valueType.toComplexType(); 32 | 33 | return macro new LazyMap<$key,$value>(new Map<$key,$value>(), $e); 34 | } 35 | 36 | private var map:Map; 37 | private var initializer:K->V; 38 | 39 | public function new(map:Map, initializer:K->V) 40 | { 41 | this.map = map; 42 | this.initializer = initializer; 43 | } 44 | 45 | public function get(key:K):V 46 | { 47 | var obj:V = map.get(key); 48 | 49 | if(obj == null) 50 | { 51 | obj = initializer(key); 52 | map.set(key, obj); 53 | } 54 | 55 | return obj; 56 | } 57 | 58 | public inline function set(key:K, value:V) map.set(key, value); 59 | public inline function exists(key:K) return map.exists(key); 60 | public inline function remove(key:K) return map.remove(key); 61 | public inline function keys():Iterator return map.keys(); 62 | public inline function iterator():Iterator return map.iterator(); 63 | } -------------------------------------------------------------------------------- /com/stencyl/utils/LazyStringMap.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.utils; 2 | 3 | #if macro 4 | import haxe.macro.Context; 5 | import haxe.macro.Expr; 6 | import haxe.macro.Type; 7 | 8 | using haxe.macro.TypeTools; 9 | #end 10 | 11 | class LazyStringMap 12 | { 13 | macro public static function fromFunction(e:Expr) 14 | { 15 | var type = Context.typeof(e); 16 | var keyType:Type = null; 17 | var valueType:Type = null; 18 | 19 | switch(type) 20 | { 21 | case TFun(args, ret): 22 | if(args.length == 1) 23 | { 24 | keyType = args[0].t; 25 | valueType = ret; 26 | } 27 | case(_): 28 | } 29 | 30 | var key = keyType.toComplexType(); 31 | var value = valueType.toComplexType(); 32 | 33 | return macro new LazyStringMap<$value>(new Map(), $e); 34 | } 35 | 36 | private var map:Map; 37 | private var initializer:String->V; 38 | 39 | public function new(map:Map, initializer:String->V) 40 | { 41 | this.map = map; 42 | this.initializer = initializer; 43 | } 44 | 45 | public function get(key:String):V 46 | { 47 | var obj:V = map.get(key); 48 | 49 | if(obj == null) 50 | { 51 | obj = initializer(key); 52 | map.set(key, obj); 53 | } 54 | 55 | return obj; 56 | } 57 | 58 | public inline function set(key:String, value:V) map.set(key, value); 59 | public inline function exists(key:String) return map.exists(key); 60 | public inline function remove(key:String) return map.remove(key); 61 | public inline function keys():Iterator return map.keys(); 62 | public inline function iterator():Iterator return map.iterator(); 63 | } -------------------------------------------------------------------------------- /com/stencyl/utils/Mathematics.hx: -------------------------------------------------------------------------------- 1 | /* 2 | * _/ _/ 3 | * _/_/_/ _/_/ _/ _/ _/ _/_/_/ _/_/ _/_/_/ _/_/_/ _/ 4 | * _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ 5 | * _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ 6 | * _/_/_/ _/_/ _/ _/_/_/ _/_/_/ _/_/ _/ _/ _/_/_/ _/ 7 | * _/ _/ _/ 8 | * _/ _/_/ _/_/ 9 | * 10 | * POLYGONAL - A HAXE LIBRARY FOR GAME DEVELOPERS 11 | * Copyright (c) 2009-2010 Michael Baczynski, http://www.polygonal.de 12 | * 13 | * Permission is hereby granted, free of charge, to any person obtaining 14 | * a copy of this software and associated documentation files (the 15 | * "Software"), to deal in the Software without restriction, including 16 | * without limitation the rights to use, copy, modify, merge, publish, 17 | * distribute, sublicense, and/or sell copies of the Software, and to 18 | * permit persons to whom the Software is furnished to do so, subject to 19 | * the following conditions: 20 | * The above copyright notice and this permission notice shall be 21 | * included in all copies or substantial portions of the Software. 22 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 23 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 24 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 25 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 26 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 27 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 28 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 29 | */ 30 | package com.stencyl.utils; 31 | 32 | /** 33 | * Additional math functions and constants. 34 | */ 35 | class Mathematics 36 | { 37 | /** Fast replacement for Math.round(x). */ 38 | inline public static function round(x:Float):Int 39 | { 40 | return Std.int(x > 0 ? x + .5 : x < 0 ? x - .5 : 0); 41 | } 42 | 43 | /** Clamps the integer x to the interval [min,max] so min <= x <= max. */ 44 | inline public static function clamp(x:Int, min:Int, max:Int):Int 45 | { 46 | return (x < min) ? min : (x > max) ? max : x; 47 | } 48 | 49 | /** Clamps a number to the interval [min,max] so min <= x <= max. */ 50 | inline public static function fclamp(x:Float, min:Float, max:Float):Float 51 | { 52 | return (x < min) ? min : (x > max) ? max : x; 53 | } 54 | } -------------------------------------------------------------------------------- /com/stencyl/utils/motion/Easing.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.utils.motion; 2 | 3 | import com.stencyl.utils.motion.EasingFunctions; 4 | 5 | class Easing 6 | { 7 | public static var linear = new Linear(); 8 | public static var sineIn = new SineIn(); 9 | public static var sineOut = new SineOut(); 10 | public static var sineInOut = new SineInOut(); 11 | public static var sineOutIn = new SineOutIn(); 12 | public static var quadIn = new QuadIn(); 13 | public static var quadOut = new QuadOut(); 14 | public static var quadInOut = new QuadInOut(); 15 | public static var quadOutIn = new QuadOutIn(); 16 | public static var cubicIn = new CubicIn(); 17 | public static var cubicOut = new CubicOut(); 18 | public static var cubicInOut = new CubicInOut(); 19 | public static var cubicOutIn = new CubicOutIn(); 20 | public static var quartIn = new QuartIn(); 21 | public static var quartOut = new QuartOut(); 22 | public static var quartInOut = new QuartInOut(); 23 | public static var quartOutIn = new QuartOutIn(); 24 | public static var quintIn = new QuintIn(); 25 | public static var quintOut = new QuintOut(); 26 | public static var quintInOut = new QuintInOut(); 27 | public static var quintOutIn = new QuintOutIn(); 28 | public static var expoIn = new ExpoIn(); 29 | public static var expoOut = new ExpoOut(); 30 | public static var expoInOut = new ExpoInOut(); 31 | public static var expoOutIn = new ExpoOutIn(); 32 | public static var circIn = new CircIn(); 33 | public static var circOut = new CircOut(); 34 | public static var circInOut = new CircInOut(); 35 | public static var circOutIn = new CircOutIn(); 36 | public static var bounceIn = new BounceIn(); 37 | public static var bounceOut = new BounceOut(); 38 | public static var bounceInOut = new BounceInOut(); 39 | public static var bounceOutIn = new BounceOutIn(); 40 | public static var backIn = new BackIn(); 41 | public static var backOut = new BackOut(); 42 | public static var backInOut = new BackInOut(); 43 | public static var backOutIn = new BackOutIn(); 44 | public static var elasticIn = new ElasticIn(); 45 | public static var elasticOut = new ElasticOut(); 46 | public static var elasticInOut = new ElasticInOut(); 47 | public static var elasticOutIn = new ElasticOutIn(); 48 | public static var warpOut = new WarpOut(); 49 | public static var warpIn = new WarpIn(); 50 | public static var warpInOut = new WarpInOut(); 51 | public static var warpOutIn = new WarpOutIn(); 52 | } -------------------------------------------------------------------------------- /com/stencyl/utils/motion/EasingConstants.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.utils.motion; 2 | 3 | class EasingConstants 4 | { 5 | public static inline var PI = 3.1415926535897932384626433832795; 6 | public static inline var PI_H = PI / 2; 7 | public static inline var LN_2 = 0.6931471805599453; 8 | public static inline var LN_2_10 = 6.931471805599453; 9 | public static inline var overshoot:Float = 1.70158; 10 | public static inline var amplitude:Float = 1; 11 | public static inline var period:Float = 0.0003; 12 | } -------------------------------------------------------------------------------- /com/stencyl/utils/motion/EasingFunction.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.utils.motion; 2 | 3 | class EasingFunction 4 | { 5 | public function new(){} 6 | 7 | public function apply(t:Float):Float 8 | { 9 | return 0; 10 | } 11 | } -------------------------------------------------------------------------------- /com/stencyl/utils/motion/TweenFloat.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.utils.motion; 2 | 3 | import tweenxcore.Tools.FloatTools; 4 | 5 | class TweenFloat extends TweenObject 6 | { 7 | public var startValue:Float; 8 | public var endValue:Float; 9 | public var value:Float; 10 | 11 | public function new() 12 | { 13 | super(); 14 | } 15 | 16 | public function tween(startValue:Float, endValue:Float, easing:EasingFunction, duration:Int):TweenFloat 17 | { 18 | this.startValue = startValue; 19 | this.endValue = endValue; 20 | value = startValue; 21 | 22 | _tween(easing, duration); 23 | 24 | return this; 25 | } 26 | 27 | override public function updateValue() 28 | { 29 | value = FloatTools.lerp(easing.apply(time/duration), startValue, endValue); 30 | } 31 | } -------------------------------------------------------------------------------- /com/stencyl/utils/motion/TweenFloat2.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.utils.motion; 2 | 3 | import tweenxcore.Tools.FloatTools; 4 | 5 | class TweenFloat2 extends TweenObject 6 | { 7 | public var startValue1:Float; 8 | public var endValue1:Float; 9 | public var value1:Float; 10 | 11 | public var startValue2:Float; 12 | public var endValue2:Float; 13 | public var value2:Float; 14 | 15 | public function new() 16 | { 17 | super(); 18 | } 19 | 20 | public function tween(startValue1:Float, endValue1:Float, startValue2:Float, endValue2:Float, easing:EasingFunction, duration:Int):TweenFloat2 21 | { 22 | this.startValue1 = startValue1; 23 | this.endValue1 = endValue1; 24 | value1 = startValue1; 25 | 26 | this.startValue2 = startValue2; 27 | this.endValue2 = endValue2; 28 | value2 = startValue2; 29 | 30 | _tween(easing, duration); 31 | 32 | return this; 33 | } 34 | 35 | override public function updateValue() 36 | { 37 | var rate = easing.apply(time/duration); 38 | value1 = FloatTools.lerp(rate, startValue1, endValue1); 39 | value2 = FloatTools.lerp(rate, startValue2, endValue2); 40 | } 41 | } -------------------------------------------------------------------------------- /com/stencyl/utils/motion/TweenManager.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.utils.motion; 2 | 3 | class TweenManager 4 | { 5 | static var activeObjects:Array = []; 6 | static var finishedObjects:Array = []; 7 | 8 | public static function resetStatics():Void 9 | { 10 | activeObjects = []; 11 | finishedObjects = []; 12 | } 13 | 14 | public static function markActive(o:TweenObject):Void 15 | { 16 | activeObjects.push(o); 17 | } 18 | 19 | public static function cancel(o:TweenObject):Void 20 | { 21 | var i = activeObjects.indexOf(o); 22 | if(i != -1) 23 | { 24 | o.active = false; 25 | o.updated = false; 26 | o.finished = false; 27 | o.paused = false; 28 | 29 | //fast splice 30 | activeObjects[i] = activeObjects[activeObjects.length - 1]; 31 | activeObjects.pop(); 32 | } 33 | } 34 | 35 | public static function finish(o:TweenObject):Void 36 | { 37 | var i = activeObjects.indexOf(o); 38 | if(i != -1) 39 | { 40 | o.update(o.duration - o.time); 41 | 42 | //fast splice 43 | activeObjects[i] = activeObjects[activeObjects.length - 1]; 44 | activeObjects.pop(); 45 | 46 | finishedObjects.push(o); 47 | } 48 | } 49 | 50 | public static function update(dt:Int):Void 51 | { 52 | var i = finishedObjects.length; 53 | 54 | while(i-- > 0) 55 | { 56 | finishedObjects.pop().updated = false; 57 | } 58 | 59 | i = activeObjects.length; 60 | 61 | while(i-- > 0) 62 | { 63 | var o:TweenObject = activeObjects[i]; 64 | 65 | o.update(dt); 66 | 67 | if(o.finished) 68 | { 69 | //fast splice 70 | activeObjects[i] = activeObjects[activeObjects.length - 1]; 71 | activeObjects.pop(); 72 | 73 | finishedObjects.push(o); 74 | } 75 | } 76 | } 77 | 78 | public static function timer(duration:Int):TweenTimer 79 | { 80 | var timer = new TweenTimer(); 81 | return timer.tween(duration); 82 | } 83 | } -------------------------------------------------------------------------------- /com/stencyl/utils/motion/TweenObject.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.utils.motion; 2 | 3 | class TweenObject 4 | { 5 | public var easing:EasingFunction; 6 | public var time:Int; 7 | public var duration:Int; 8 | 9 | public var active:Bool; 10 | public var paused:Bool; 11 | public var updated:Bool; 12 | public var finished:Bool; 13 | 14 | public var onUpdate:Void->Void; 15 | public var onComplete:Void->Void; 16 | 17 | public function new() 18 | { 19 | active = false; 20 | finished = false; 21 | paused = false; 22 | } 23 | 24 | public function _tween(easing:EasingFunction, duration:Int) 25 | { 26 | if(easing == null) 27 | easing = Easing.linear; 28 | 29 | this.easing = easing; 30 | this.duration = duration; 31 | 32 | if(!active) 33 | { 34 | TweenManager.markActive(this); 35 | } 36 | 37 | time = 0; 38 | active = true; 39 | updated = false; 40 | finished = false; 41 | paused = false; 42 | 43 | if(duration == 0) 44 | { 45 | this.duration = 1; 46 | TweenManager.finish(this); 47 | } 48 | } 49 | 50 | public function update(dt:Int):Void 51 | { 52 | if(paused) return; 53 | 54 | time += dt; 55 | if(time > duration) 56 | time = duration; 57 | 58 | updateValue(); 59 | updated = true; 60 | 61 | if(time == duration) 62 | { 63 | active = false; 64 | finished = true; 65 | if(onUpdate != null) 66 | onUpdate(); 67 | if(onComplete != null) 68 | onComplete(); 69 | } 70 | else if(onUpdate != null) 71 | onUpdate(); 72 | } 73 | 74 | public function updateValue(){} 75 | 76 | public function doOnUpdate(onUpdate:Void->Void):TweenObject 77 | { 78 | this.onUpdate = onUpdate; 79 | return this; 80 | } 81 | 82 | public function doOnComplete(onComplete:Void->Void):TweenObject 83 | { 84 | this.onComplete = onComplete; 85 | return this; 86 | } 87 | } -------------------------------------------------------------------------------- /com/stencyl/utils/motion/TweenTimer.hx: -------------------------------------------------------------------------------- 1 | package com.stencyl.utils.motion; 2 | 3 | class TweenTimer extends TweenObject 4 | { 5 | public function new() 6 | { 7 | super(); 8 | } 9 | 10 | public function tween(duration:Int):TweenTimer 11 | { 12 | _tween(Easing.linear, duration); 13 | return this; 14 | } 15 | 16 | override public function updateValue() 17 | { 18 | } 19 | } -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | /pages/ 2 | /xml/ -------------------------------------------------------------------------------- /docs/compile-rtti.hxml: -------------------------------------------------------------------------------- 1 | -D display 2 | -D doc_gen 3 | -D openfl_doc_gen 4 | ImportAll 5 | -lib box2d 6 | -lib cloner 7 | -lib com.stencyl.gestures 8 | -lib com.stencyl.joystick 9 | -lib com.stencyl.label 10 | -lib debug-console 11 | -lib lime 12 | -lib mbs 13 | -lib openfl 14 | -lib polygonal-ds 15 | -lib stencyl 16 | -lib tweenxcore 17 | --no-output 18 | 19 | --each 20 | 21 | # Flash doesn't actually define flash because some issues in openfl prevent flash docs from being merged with other platforms. 22 | # If those issues are ever resolved, change -cpp to -swf here. Otherwise, flash_doc_gen can be used to modify flash docs. 23 | 24 | -xml xml/Flash.xml 25 | -cpp obj/docs 26 | -D flash_doc_gen 27 | 28 | --next 29 | 30 | -xml xml/Windows.xml 31 | -cpp obj/docs 32 | -D native 33 | -D windows 34 | -lib com.stencyl.native 35 | 36 | --next 37 | 38 | -xml xml/Mac.xml 39 | -cpp obj/docs 40 | -D native 41 | -D mac 42 | -lib com.stencyl.native 43 | 44 | --next 45 | 46 | -xml xml/Linux.xml 47 | -cpp obj/docs 48 | -D native 49 | -D linux 50 | -lib com.stencyl.native 51 | 52 | --next 53 | 54 | -xml xml/iOS.xml 55 | -cpp obj/docs 56 | -D native 57 | -D ios 58 | -lib com.stencyl.admob 59 | -lib com.stencyl.gamecenter 60 | -lib com.stencyl.purchases 61 | -lib com.stencyl.native 62 | 63 | --next 64 | 65 | -xml xml/Android.xml 66 | -cpp obj/docs 67 | -D native 68 | -D android 69 | -lib com.stencyl.admob 70 | -lib com.stencyl.google-play-games 71 | -lib com.stencyl.purchases 72 | -lib com.stencyl.native 73 | 74 | --next 75 | 76 | -xml xml/HTML5.xml 77 | -js obj/docs 78 | -D html5 -------------------------------------------------------------------------------- /docs/generate-api-docs.bat: -------------------------------------------------------------------------------- 1 | haxe compile-rtti.hxml 2 | haxe run-dox.hxml -------------------------------------------------------------------------------- /docs/generate-api-docs.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | haxe compile-rtti.hxml 4 | haxe run-dox.hxml -------------------------------------------------------------------------------- /docs/run-dox.hxml: -------------------------------------------------------------------------------- 1 | -cmd haxelib run dox -i xml -in stencyl --title "Stencyl API Reference" -D website "https://www.stencyl.com/api/haxe" -D source-path "https://github.com/Stencyl/stencyl-engine/tree/develop/" -D textColor 0x777777 --toplevel-package com.stencyl -------------------------------------------------------------------------------- /docs/scripts/MyScripts.hx: -------------------------------------------------------------------------------- 1 | package scripts; 2 | 3 | class MyScripts 4 | { 5 | } -------------------------------------------------------------------------------- /haxelib.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "stencyl", 3 | "url": "http://www.stencyl.com", 4 | "license": "MIT", 5 | "tags": [ "stencyl", "flash", "cpp" ], 6 | "description": "Stencyl.", 7 | "version": "4.1.0", 8 | "binaryversion": "1", 9 | "releasenote": "", 10 | "contributors": [ "" ], 11 | "dependencies": {} 12 | } -------------------------------------------------------------------------------- /include.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |