Advertisement
Guest User

Untitled

a guest
Oct 21st, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. var vertices:Array<Float> = new Array();
  2. var indices:Array<Int> = new Array();
  3. var uvt:Array<Float> = new Array();
  4. var bitmap:flash.display.Shape;
  5.  
  6. var image:flash.display.BitmapData=cast(getImageForActor(__theActor), BitmapData);
  7.  
  8. bitmap = new flash.display.Shape();
  9.  
  10. var width=Std.int(image.width);
  11. var height=Std.int(image.height);
  12.  
  13. vertices = [0,0, width,0, 0,height,width,height] ;
  14.  
  15. indices = [0, 1, 2, 1, 3, 2];
  16.  
  17. uvt = [0,0,1, 1,0,1, 0,1,1, 1,1,1];
  18.  
  19.  
  20. var struct = { a:0, b:width};
  21.  
  22. Actuate.tween(struct, __theDuration, { a:width/2, b:width/2 } ).onUpdate(function() {
  23. // we push pixels to top
  24. if(uvt[5] > 0) uvt[5]=uvt[5]-0.01;else{uvt = [0,0,0, 0,0,0, 0,0,0, 0,0,0]; }
  25.  
  26. // top is pushed together
  27. // struct is tweened from 0,width to width/2,width/2 in 2 seconds
  28. vertices[0] = struct.a;
  29. vertices[2] = struct.b;
  30.  
  31. bitmap.graphics.clear();
  32. bitmap.graphics.beginBitmapFill(image);
  33.  
  34. bitmap.graphics.drawTriangles(openfl.Vector.ofArray(vertices), openfl.Vector.ofArray(indices), openfl.Vector.ofArray(uvt));
  35.  
  36. bitmap.graphics.endFill();
  37.  
  38. var bmp=new BitmapData(image.width,image.height);
  39. bmp.draw(bitmap);
  40. var bitmapwrapper = new BitmapWrapper(new Bitmap( bmp ));
  41.  
  42. attachImageToActor(bitmapwrapper, __theActor, 0,0, 1); // 1 = front
  43.  
  44. } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement