-
-
Save PrimaryFeather/03de478dabd456e1985b411b8b0e22e5 to your computer and use it in GitHub Desktop.
The source of the demo used to showcase the GodRayPlane class in the Starling Wiki.
This file contains 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 flash.geom.Point; | |
import flash.ui.Keyboard; | |
import starling.core.Starling; | |
import starling.display.DisplayObjectContainer; | |
import starling.display.Image; | |
import starling.events.KeyboardEvent; | |
import starling.events.Touch; | |
import starling.events.TouchEvent; | |
import starling.events.TouchPhase; | |
import starling.extensions.GodRayPlane; | |
import starling.textures.Texture; | |
public class Demo_GodRayPlane extends DisplayObjectContainer | |
{ | |
[Embed(source="../assets/water.jpg")] | |
private static const BackgroundAsset:Class; | |
private var _godRays:GodRayPlane; | |
public function Demo_GodRayPlane() | |
{ | |
var background:Image = new Image(Texture.fromEmbeddedAsset(BackgroundAsset)); | |
addChild(background); | |
_godRays = new GodRayPlane(background.width, background.height); | |
_godRays.speed = 0.1; | |
_godRays.fade = 1; | |
_godRays.size = 0.065; | |
_godRays.shear = 0.5; | |
_godRays.skew = -0.26; | |
_godRays.contrast = 2; | |
addChild(_godRays); | |
Starling.juggler.add(_godRays); | |
addEventListener(TouchEvent.TOUCH, onTouch); | |
Starling.current.stage.addEventListener(KeyboardEvent.KEY_UP, onKey); | |
} | |
private var _testProperty:String = "skew"; | |
private function onKey(event:KeyboardEvent, keyCode:uint):void | |
{ | |
switch (keyCode) | |
{ | |
case Keyboard.P: _testProperty = "speed"; break; | |
case Keyboard.I: _testProperty = "size"; break; | |
case Keyboard.K: _testProperty = "skew"; break; | |
case Keyboard.H: _testProperty = "shear"; break; | |
case Keyboard.F: _testProperty = "fade"; break; | |
case Keyboard.C: _testProperty = "contrast"; break; | |
} | |
trace("now modifying " + _testProperty); | |
} | |
private function onTouch(event:TouchEvent):void | |
{ | |
var touch:Touch = event.getTouch(this, TouchPhase.MOVED); | |
if (touch) | |
{ | |
var movement:Point = touch.getMovement(this); | |
var delta:Number = movement.x / 200; | |
_godRays[_testProperty] += delta; | |
trace("godRays." + _testProperty + " = " + _godRays[_testProperty]); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment