Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 1.51 KB | None | 0 0
  1. package;
  2.  
  3. import com.helpers.Point;
  4. import kha.Color;
  5. import kha.Framebuffer;
  6. import kha.Image;
  7. import com.imageAtlas.AtlasGenerator;
  8. import kha.Assets;
  9. import com.gEngine.tempStructures.Bitmap;
  10.  
  11. class AtlasTest{
  12.  
  13.     var bitmapA:Bitmap = new Bitmap();
  14.     var bitmapB:Bitmap = new Bitmap();
  15.  
  16.     var img:kha.Image = Image.createRenderTarget(2024,2024);
  17.     var atlas:Image;
  18.     var atlas2:Image;
  19.  
  20.     public function new(){
  21.         Assets.loadEverything(onDone);
  22.     }
  23.  
  24.  
  25.     function onDone(){
  26.         bitmapB.image = Assets.images.hero;
  27.         bitmapB.width = bitmapB.image.width;
  28.         bitmapB.height = bitmapB.image.height;
  29.         bitmapB.x = 0;
  30.         bitmapB.y = 0;
  31.         bitmapB.extrude = 0;
  32.         bitmapB.maxUV = new Point(1.0,1.0);
  33.         bitmapB.minUV = new Point(0.0,0.0);
  34.        
  35.          bitmapA.image = Assets.images.tiles;
  36.         bitmapA.width = bitmapB.image.width;
  37.         bitmapA.height = bitmapB.image.height;
  38.         bitmapA.x = 0;
  39.         bitmapA.y = 0;
  40.         bitmapA.extrude = 0;
  41.         bitmapA.maxUV = new Point(1.0,1.0);
  42.         bitmapA.minUV = new Point(0.0,0.0);
  43.  
  44.         atlas = AtlasGenerator.generate(2024,2024,[bitmapA,bitmapB]);
  45.         atlas2 = AtlasGenerator.generate(2024,2024,[bitmapB,bitmapA]);
  46.  
  47.         kha.System.notifyOnFrames(onFrames);
  48.     }
  49.  
  50.     function onFrames(a:Array<Framebuffer>){
  51.         var g = a[0].g2;
  52.         g.begin(true,Color.Cyan);
  53.         g.drawImage(atlas,0,0);
  54.         g.drawImage(atlas2,0,0);
  55.         g.end();
  56.     }
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement