Advertisement
Guest User

Shape3D.ts

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