Problem statement :
Stencyl 4.0.4 has a major drawing problem that crash Microsoft Edge.
Stencyl 4.0.4 has a major drawing problem that crash Microsoft Edge.
The arbitrary Code:
flash.display.Graphics cannot be initialised directly and the game wont work without initialisation
Therefore we use this.gr = Engine.engine.transitionLayer.graphics;
The same for the Graphics variable for the text drawing
If the Graphics are not initialised, the game will not work and will stop working when it is time to use the code.
Adding this to the Design mode
Requires the use of custom import. Advanced > Custom Import. And the use of custom code
In this case,
custom import: import scripts.H;
custom code: public var dt:H = new H();
For copy and paste ,
Flash.geom.Matrix is not used but proposed extension as text drawing. Link will be inserted here when Stencyl-nator has the solution.
Full code for direct copy and paste into Stencyl Freeform mode:
package scripts;
{
import com.stencyl.Engine; // initially given in freeform code
import flash.display.BitmapData;
import flash.display.Graphics;
package scripts;
{
class H
{
public var a_fi:Float; // fill opacity
public var a_li:Float; // line opacity
public var c_fi:Int; // fill color
public var c_li:Int; // line color
public var gr:Graphics; // cannot be initialised
public var lit:Float; // line thickness
public function new
{
this.a_fi = 1;
this.a_li = 1;
this.c_fi = 0;
this.c_fi = 0;
this.gr = Engine.engine.transitionLayer.graphics;
// needed to be initialised but cannot be done via new Graphics()
}
public function d_rec(x,y,w,h): Void // fills and draws rectangles
{
if(this.lit==0){this.gr.lineStyle();}
else {this.gr.lineStyle(this.lit,this.c_li,this.a_li);}
this.gr.beginFill(this.c_fi,this.a_fi);
this.gr.drawRect(x,y,w,h);
this.gr.endFill();
}
public function d_rec_li(x,y,w,h): Void // draws ONLY the outline
{
this.gr.lineStyle(this.lit,this.c_li,this.a_li);
this.gr.drawRect(x,y,w,h);
this.gr.lineStyle();
}
public function f_rec(x,y,w,h): Void // Only filling. No outline
{
this.gr.lineStyle();
this.gr.beginFill(this.c_fi,this.a_fi);
this.gr.drawRect(x,y,w,h);
this.gr.endFill();
}
}
}
No comments:
Post a Comment