Created
January 12, 2013 02:45
-
-
Save sebbdk/4515787 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package | |
| { | |
| import asset.BadGermGraph; | |
| import away3d.animators.UVAnimationSet; | |
| import away3d.animators.UVAnimationState; | |
| import away3d.animators.UVAnimator; | |
| import away3d.animators.data.UVAnimationFrame; | |
| import away3d.animators.nodes.UVClipNode; | |
| import away3d.containers.View3D; | |
| import away3d.entities.Mesh; | |
| import away3d.entities.Sprite3D; | |
| import away3d.materials.TextureMaterial; | |
| import away3d.primitives.PlaneGeometry; | |
| import away3d.utils.Cast; | |
| import dk.sebb.engine.creature.Creature; | |
| import dk.sebb.engine.util.Key; | |
| import dk.sebb.engine.util.SpriteBitmap; | |
| import dk.sebb.engine.world.World; | |
| import dk.sebb.engine.world.WorldEvent; | |
| import dk.sebb.outside.d3.creature.CreatureView; | |
| import dk.sebb.outside.d3.creature.PlayerView; | |
| import flash.display.Bitmap; | |
| import flash.display.Sprite; | |
| import flash.display.StageAlign; | |
| import flash.display.StageScaleMode; | |
| import flash.events.Event; | |
| import flash.geom.Vector3D; | |
| [SWF(backgroundColor="#333333", frameRate="120", quality="HIGH")] | |
| public class UVAnimationTest extends Sprite | |
| { | |
| private var _view:View3D; | |
| private var controller:World; | |
| private var sprite:Mesh; | |
| public function UVAnimationTest() | |
| { | |
| stage.scaleMode = StageScaleMode.NO_SCALE; | |
| stage.align = StageAlign.TOP_LEFT; | |
| Key.init(stage); | |
| super(); | |
| _view = new View3D(); | |
| addChild(_view); | |
| _view.camera.z = -600; | |
| _view.camera.y = 500; | |
| _view.camera.lookAt(new Vector3D()); | |
| addEventListener(Event.ADDED_TO_STAGE, onAddedToStage); | |
| createSprite(); | |
| testAnimation(); | |
| } | |
| public function createSprite():void { | |
| var b:Bitmap = SpriteBitmap.getBitmapFromSprite(new BadGermGraph(), 512, 512); | |
| var mat:TextureMaterial = new TextureMaterial(Cast.bitmapTexture(b)); | |
| mat.alphaThreshold = .5; | |
| sprite = new Mesh(new PlaneGeometry(100, 100), mat); | |
| _view.scene.addChild(sprite); | |
| } | |
| public function testAnimation():void { | |
| var frame01:UVAnimationFrame = new UVAnimationFrame(1,1); | |
| var frame02:UVAnimationFrame = new UVAnimationFrame(25,25); | |
| var uvClipNode:UVClipNode = new UVClipNode(); | |
| uvClipNode.addFrame(frame01, 100); | |
| uvClipNode.addFrame(frame02, 100); | |
| var animationState:UVAnimationState = new UVAnimationState(uvClipNode); | |
| var animationSet:UVAnimationSet = new UVAnimationSet(); | |
| animationSet.addState('test', animationState); | |
| var animator:UVAnimator = new UVAnimator(animationSet); | |
| sprite.animator = animator; | |
| trace("123"); | |
| animator.play('test'); | |
| } | |
| public function onAddedToStage(evt:Event):void { | |
| //setup the render loop | |
| addEventListener(Event.ENTER_FRAME, _onEnterFrame); | |
| stage.addEventListener(Event.RESIZE, onResize); | |
| } | |
| private function _onEnterFrame(e:Event):void{ | |
| _view.render(); | |
| } | |
| private function onResize(event:Event = null):void { | |
| _view.width = stage.stageWidth; | |
| _view.height = stage.stageHeight; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment