Advertisement
Guest User

Shape3DImage.ts

a guest
Dec 27th, 2014
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /// <reference path="defs/PIXI.d.ts" />
  2.  
  3. module djankey {
  4.     export class Shape3DImage extends PIXI.Sprite {
  5.         private sid:number;
  6.         public power:number = 100+50*Math.random();
  7.         private vx:number;
  8.         private vy:number;
  9.         private rSpeed:number = Math.random() / 300;
  10.  
  11.         constructor(tex:PIXI.Texture, id:number) {
  12.             super(tex);
  13.  
  14.             this.sid = id;
  15.  
  16.             var speed:number = 10*(.2 + Math.random());
  17.             var a3:number = 2 * Math.PI * Math.random();
  18.             this.vx = Math.sin(a3) * speed;
  19.             this.vy = Math.cos(a3) * speed;
  20.  
  21.             this.interactive = false;
  22.         }
  23.  
  24.         public update = (t:number):void => {
  25.             var ft:number = this.sid + t * this.rSpeed;
  26.             this.rotation = this.sid + t * this.rSpeed;
  27.             this.scale.x = Math.sin(ft);
  28.             this.scale.y = Math.cos(ft);
  29.             this.power--;
  30.             this.alpha = this.power / 100;
  31.             this.vy += .1;
  32.             this.vx *= .95;
  33.             this.vy *= .95;
  34.             this.x += this.vx;
  35.             this.y += this.vy;
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement