blob: adc63589b41d791ea80edb4b12355a12b28bfe82 [file] [log] [blame]
{
"name": "ActionSwift3",
"version": "1.52",
"summary": "AS3 SDK in Swift",
"description": "![ActionSwift logo](https://github.com/craiggrummitt/ActionSwift3/blob/master/ActionSwift.png)\n \n Swift is awesome - but do you ever reminisce about the old days of ActionScript 3.0? The old days of MovieClips, DisplayObjects, Sprites, SimpleButtons, EventDispatchers - oh and who can forget gotoAndPlay? Well, now you can enjoy iOS native development using the power of Swift syntax but with the AS3 SDK! Whaa? How is this possible? Is this heresy?\n\n **ActionSwift3**\n\nUnderneath the hood ActionSwift3 is based on the SpriteKit Framework but ActionSwift 3 SDK is based on familiar AS3 SDK classes:\n\n* DisplayObject\n* InteractiveObject\n* DisplayObjectContainer\n* Sprite\n* Graphics\n* Stage\n* MovieClip\n* SimpleButton\n* TextField\n* TextFormat\n* Sound\n* SoundChannel\n* EventDispatcher\n* Event\n* EventHandler\n* Touch\n* TouchEvent (in a touch environment TouchEvent makes more sense to use than MouseEvent)\n\nEasing classes are also included for convenience from [here](https://github.com/craiggrummitt/SpriteKitEasingSwift).\n\nAPI documentation can be found at [cocoadocs](http://cocoadocs.org/docsets/ActionSwift3/)\n\n## Installation\n\nActionSwift is available through [CocoaPods](https://cocoapods.org/pods/ActionSwift3). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod \"ActionSwift3\"\n```\n\nDon't forget to import the Pod where you would like to use it:\n\n```Swift\nimport ActionSwift3\n```\n\nAlternatively, if you would like access to the example project as well, clone the github project [here](https://github.com/craiggrummitt/ActionSwift3).\n\n**ActionSwift**\n\nActionSwift is a sample project that you can use to play with ActionSwift3. Start with taking a look at GameViewController.swift. GameViewController does the following:\n\n1. Sets up the stage.\n2. Creates a 'play' sprite that draws a circle containing a triangle.\n3. Creates a 'stop' sprite that draws a rectangle containing a rectangle.\n4. Creates a movieclip that displays textures defined by an array of strings referring to the images in the folder 'images.atlas'. \n5. Shows how to create an event listener by setting up clicks on all three sprites. The stop and play sprites 'stop' and 'play' the movieclip. Touching the movieclip activates a drag-drop operation.\n\n![Screenshot](https://github.com/craiggrummitt/ActionSwift3/blob/master/screenshot.png)\n\n**How to use ActionSwift3**\n\nHere is some sample code to get your head around how to use ActionSwift3.\n\n***Stage***\n\nTo begin with, you need to set up the Stage in a ViewController that contains a SKView(this is done for you automatically if you set up a Game-SpriteKit project)\n\n```Swift\nlet stage = Stage(self.view as! SKView)\n```\n\n***Sprite***\n\nYou can now call familiar methods on the stage. For example, you could instantiate a sprite, and draw a rectangle on its graphics property, and then add this sprite to the stage:\n\n```Swift\nlet sprite = Sprite()\nsprite.graphics.beginFill(UIColor.redColor())\nsprite.graphics.drawRect(10,10,100,44)\nsprite.name = \"shapes\"\nstage.addChild(sprite)\n```\n\n***MovieClip***\n\nTo create a movieclip, you will need images within a folder with the extension 'atlas' in your project (eg.'images.atlas'). This will automatically generate a Texture Atlas. Set up an array of these image file names, and pass them in when you instantiate a MovieClip. These will now be the 'frames' of your movieclip, which you will be able to call familiar methods - gotoAndPlay(), gotoAndStop(), stop() and play(). Use Stage.size to get the dimensions of the device. Oh and x=0, y=0 is the top left of the stage. Hooray!\n\n```Swift\nlet walkingTextures = [\"walking1\",\"walking2\",\"walking3\"]\nlet movieClip = MovieClip(textureNames: walkingTextures)\nmovieClip.x = 0\nmovieClip.y = Stage.size.height - movieClip.height\nstage.addChild(movieClip)\n```\n\n**SimpleButton**\n\nYou can create a SimpleButton object, with an up and down state(not much point of over states on touch screens!) You can use sprites(with shapes on the graphics object) or movieclips(with textures) as the states.\n\n```Swift\nlet play = SimpleButton(upState: playUpState, downState: playDownState)\nstage.addChild(sprite)\n```\n\n***TextField***\n\nUse familiar syntax to create a textfield. Build the basics of the textfield using the TextField class, and then apply text formatting to the defaultTextFormat property, using the TextFormat class.\n\n```Swift\nlet text = TextField()\ntext.width = 200\ntext.text = \"Salutations to you, world\"\n\nlet textFormat = TextFormat(font: \"ArialMT\", size: 20, leading: 20, color: UIColor.blackColor(), align:.Center)\ntext.defaultTextFormat = textFormat\n\nstage.addChild(text)\n```\n\n***Sound***\n\nUse sound to play sounds included in your project - a big difference though - now wav files are supported as well as mp3. *Hooray!* Loop the audio, or play it from a point in the file. As per the strange AS3 API, use SoundChannel to stop the sound.\n\n```Swift\nsound = Sound(name: \"ButtonTap.wav\")\nsound.play()\n```\n\n***EventDispatcher***\n\nJust as you would expect, Sprites, SimpleButtons and MovieClips will dispatch events. As Swift is not able to check equality between two functions, an additional class called 'EventHandler' stores the EventHandler, along with a string representing the EventHandler, that can be checked for equality. For example, here's how to set up an enterFrame event handler:\n\n```Swift\nmovieClip.addEventListener(EventType.EnterFrame.rawValue, EventHandler(enterFrame, \"enterFrame\"))\nfunc enterFrame(event:Event) -> Void {\n trace(\"This is called every frame\")\n}\n```\n\n***trace***\n\nOh yeah - and trace is back!\n\n```Swift\ntrace(\"This is the most amazing thing I've ever seen, trace is back! How did they do this?\")\n```\n\n**Enhancements**\n\nActionSwift3 is a work in progress, feel free to contribute! \n\nIdeas for enhancements:\n\n* Date\n* XML\n* Add more complex shapes on Graphics\n\n**Updates**\n\n1.1\n* Added int and Boolean data types\n\n1.2\n* Added TextField\n* Resolved issue with stage updates not propogating\n* Added license\n\n1.3\n* Added SimpleButton\n* Added UIColor extension for hexidecimal support\n\n1.4\n* Added Sound, SoundChannel\n\n1.5\n* Updated for Swift 2\n\n***Credits***\n\n* \"Walking animation\" by [Kyoux](http://kyoux.deviantart.com/)\n* \"ActionScript\" by Adobe Systems Inc.\n* \"Swift\" by Apple Inc.\n* \"Swift logo\" by Apple Inc.",
"homepage": "https://github.com/craiggrummitt/ActionSwift3",
"license": {
"type": "MIT",
"file": "LICENSE"
},
"authors": "Craig Grummitt",
"social_media_url": "http://twitter.com/craiggrummitt",
"platforms": {
"ios": "8.0"
},
"source": {
"git": "https://github.com/craiggrummitt/ActionSwift3.git",
"commit": "fc0aa701c3c01ea965f130b8834da6379f342040",
"tag": "1.52"
},
"source_files": "ActionSwift3/**/*"
}