- #USE SPRITE SHEET FOR 2D GAME ADOBE FLASH ACTIONSCRIPT 3.0 INSTALL#
- #USE SPRITE SHEET FOR 2D GAME ADOBE FLASH ACTIONSCRIPT 3.0 SOFTWARE#
- #USE SPRITE SHEET FOR 2D GAME ADOBE FLASH ACTIONSCRIPT 3.0 CODE#
- #USE SPRITE SHEET FOR 2D GAME ADOBE FLASH ACTIONSCRIPT 3.0 DOWNLOAD#
Resize Stage3D to continue to fit screen Protected function onResizeEvent(event:Event) : void Trace("Error while setting up Stage3D: "+e.errorID+" - " +e.text) Private function errorHandler(e:ErrorEvent):void or if the html does not include wmode=direct
this can be called when using an old version of Flash Trace("Stage3D context created! Init sprite engine.") Private function onContext3DCreate(e:Event):void and is ready for rendering using stage3d this is called when the 3d card has been set up Those with decent gaming rigs will get fantastic framerate like you've never seen in a Flash game before. It doesn't run very fast but at least everyone will be able to play your game.
#USE SPRITE SHEET FOR 2D GAME ADOBE FLASH ACTIONSCRIPT 3.0 SOFTWARE#
In the case of errors due to running old Flash plugins, in future versions of this game we might want to output a message and remind the user to upgrade, but for now this error is simply ignored.įor users with old video cards (or drivers) that don't support shader model 2.0, the good news is that Flash 11 is smart enough to provide a software renderer. These errors can also happen if the user is running an old version of Flash or if they don't have a video card capable of handling pixel shader 2.0.Īdd the following functions that detect any events that might be triggered as specified above.
#USE SPRITE SHEET FOR 2D GAME ADOBE FLASH ACTIONSCRIPT 3.0 CODE#
We also want to detect any errors that may occur, especially since Stage3D content does not run if the HTML embed code that loads your SWF doesn't include the parameter "wmode=direct". This can take a while (a fraction of a second) as your video card is configured for hardware rendering, so we need to wait for the onContext3DCreate event. 3D(Context3DRenderMode.AUTO) Īfter setting some stage-specific properties, we request a Stage3D context. (Event.CONTEXT3D_CREATE, onContext3DCreate) _gui = new GameGUI("Simple Stage3D Sprite Demo v1") Stage.addEventListener(Event.RESIZE, onResizeEvent) Stage.scaleMode = StageScaleMode.NO_SCALE RemoveEventListener(Event.ADDED_TO_STAGE, init) Private function init(e:Event = null):void Private var _spriteStage : LiteSpriteStage Įlse addEventListener(Event.ADDED_TO_STAGE, init) For simplicity, we will be doing most of our game in a single little class that inherits from the Flash Sprite class as follows. Doing things this way allows for the future use of a preloader. The next step is to wait for our game to appear on the Flash stage. Add the following to the very top of your Main.as file. To begin with, we will need to import all the Stage3D functionality required.
Now that our blank project is set up, let's dive in and do some coding.
#USE SPRITE SHEET FOR 2D GAME ADOBE FLASH ACTIONSCRIPT 3.0 INSTALL#
Once you're all set up (and you've allowed it to install the latest version of the Flex compiler automatically), fire it up and start a new "AS3 Project."
#USE SPRITE SHEET FOR 2D GAME ADOBE FLASH ACTIONSCRIPT 3.0 DOWNLOAD#
If you don't already have it, be sure to download and install FlashDevelop. FlashDevelop is great because it is 100% freeware - no need to buy any expensive tools to get the best AS3 IDE around. We are going to build it using pure AS3, compiled in FlashDevelop ( read more about it here). In this 6-part tutorial series, we are going to program a simple 2D shoot-'em-up that delivers mind-blowing rendering performance. It isn't half as hard as some people say it is, and you won't need to learn assembly language AGAL opcodes. We'll make a side-scrolling shooter inspired by retro arcade titles such as R-Type or Gradius in ActionScript using Flash 11's Stage3D API. This will enable us to render tons of sprites on screen at a silky-smooth 60fps. We can render simple geometry in the form of 2D squares (called quads) and draw them on a flat plane. Instead of using old-fashioned Flash sprites on the DisplayList or last-gen blitting techniques as popularized by engines such as FlashPunk and Flixel, the new breed of 2D games uses the power of your video card's GPU to blaze through rendering tasks at up to 1000x the speed of anything Flash 10 could manage.Īlthough it has 3D in its name, this new API is also great for 2D games. The incredible speed of the new Flash 11 hardware accelerated Stage3D API is just begging to be used for 2D games. If you're hoping to take your Flash games to the next level and are looking for loads of eye-candy and amazing framerate, Stage3D is going to be your new best friend.