zaterdag 19 december 2015

Stencyl / HaXe : Create graphics using pixel code instead of draw event

For: Stencyl
Version: 3

Create graphics without a draw event:



var script:com.stencyl.behavior.Script=null;


script = new com.stencyl.behavior.Script(Engine.engine);


var source:nme.display.BitmapData = new nme.display.BitmapData(300,300);


var bi:Int=0;
var bj:Int=0;
  var brc:Int=0;
  var bgc:Int=0;
var bbc:Int=0;
  for(bi in 1 ... 1020){
   for(bj in 1 ... 1020){
        var pixel=bi;
        brc=pixel;


        bgc=pixel+brc;
        bbc=pixel+bgc;
      
  source.setPixel(bi,bj,(brc<<16|bgc<<8|bbc));
}
}


// This code attaches the image to the HUD (main-screen overlapping everyting)
script.attachImageToHUD(new Bitmap(source), 0,0);

You could use the bitmap for actors or other things as well.

Geen opmerkingen:

Een reactie posten