Advertisement
Guest User

Particles should converge to the center of the rectangle

a guest
Mar 30th, 2018
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 0.89 KB | None | 0 0
  1. import haxepunk.Entity;
  2. import haxepunk.HXP;
  3. import haxepunk.Scene;
  4. import haxepunk.graphics.Image;
  5. import haxepunk.graphics.Graphiclist;
  6. import haxepunk.graphics.emitter.StaticEmitter;
  7. import haxepunk.utils.Ease;
  8.  
  9. class MainScene extends Scene
  10. {
  11.     private var se:StaticEmitter;
  12.     private var e:Entity;
  13.    
  14.     override public function begin()
  15.     {
  16.         e = new Entity();
  17.         se = new StaticEmitter("graphics/particle.png");
  18.         se.newType("tell");
  19.         se.setMotion("tell", 0, 50, 0.2, 360, 10, 0.1, Ease.sineIn, true);
  20.         var i = Image.createRect(100, 50, 0xff0000);
  21.         i.centerOrigin();
  22.         var g = new Graphiclist();
  23.         g.add(i);
  24.         g.add(se);
  25.         e.graphic = g;
  26.        
  27.         add(e);
  28.     }
  29.    
  30.     override public function update()
  31.     {
  32.         super.update();
  33.         se.emit("tell");
  34.         e.x = Math.cos(haxe.Timer.stamp()) * 100 + HXP.halfWidth;
  35.         e.y = Math.sin(haxe.Timer.stamp()) * 100 + HXP.halfHeight;
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement