setScroll play
/**
* Copyright mfc314159 ( http://wonderfl.net/user/mfc314159 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/rq0j
*/
package {
import flash.display.*;
import flash.events.*;
import flash.filters.*;
import flash.geom.*;
import flash.media.*;
import flash.net.*;
import org.papervision3d.core.effects.*;
import org.papervision3d.core.effects.utils.*;
import org.papervision3d.view.layer.*;
import org.papervision3d.objects.*;
import org.papervision3d.view.*;
import org.papervision3d.materials.*;
import org.papervision3d.objects.primitives.*;
//Playing with basic effects and setScroll
//CLICK to do make stuff happen
public class Main extends BasicView {
private const piE:Number = Math.PI / 180;
private var cx:int = stage.stageWidth * .5;
private var cy:int = stage.stageHeight * .5;
private var newX:Number;
private var newY:Number;
private var shooting:Boolean = false;
private var count:int;
private var pwr:Number = 0.00;
private var sphere:Sphere;
private var bfx:BitmapEffectLayer;
public function Main() {
viewport.opaqueBackground = 0x000000;
bfx = new BitmapEffectLayer(viewport, 1000, 700);
bfx.addEffect(new BitmapLayerEffect(new BlurFilter(16, 16, 2)));
bfx.setScroll(0,-10);
viewport.containerSprite.addLayer(bfx);
var material:WireframeMaterial = new WireframeMaterial(0x0099FF, 1 ,3);
sphere = new Sphere(material, 50, 5, 4);
scene.addChild(sphere);
bfx.addDisplayObject3D(sphere);
startRendering();
stage.addEventListener(MouseEvent.CLICK, shoot);
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseHand);
addEventListener(Event.ENTER_FRAME, loop);
}
private function shoot(evt:MouseEvent) {
if(shooting == false) { shooting = true; }
}
private function punk() {
if(count == 0) {
pwr = 100;
count = 1;
} else {
pwr -= 5;
if(pwr < 0) {
shooting = false;
pwr = 0;
count = 0;
}
}
}
private function mouseHand(evt:MouseEvent) {
newX = (evt.stageX - cx) / 500;
newY = (evt.stageY - cy) / 700;
trace(pwr, newX, pwr, newY);
}
private function loop(e:Event):void {
if(shooting) { punk(); }
//
bfx.setScroll(newX * pwr, newY * pwr);
sphere.yaw(1);
sphere.roll(2);
sphere.pitch(3);
}
}
}