Recently H5 small game more popular, originally I was doing cocos2dx, a start want to use it's JS version.
Unfortunately looking at JS really big head. So chose Egret,egret use Typescript, learned object-oriented, get started or relatively fast, and the API is clear.
Here is a record of the problems encountered.
1. Error: #1006: The provided displayobject must be a child of the caller
Such as:
Parent.removechild (Child)
In fact, child is not the parent node
One case is added to the stage and mistakenly thought to be on the class itself.
One case is that child is instantiated multiple times and is overwritten, at which time the child is not addchild.
2, coordinate system, Anchor point problem
coordinate system is the upper left corner is the origin of the coordinates.
The anchor point of the Egret, which uses the distance from the upper left rather than the center of the object, is more troublesome when calculating.
Fortunately, someone has written the conversion tool class, Https://github.com/eperfect/AnchorUtil
Use the latest Egret to modify:
All comments on the IF (Egret.gui && egret.gui.UIComponent) code
You can add a new function to set the anchor point easily
public static setanchorxy (Target:egret. Displayobject,x:number,y:number): void {
target["Anchorx"] = x;
target["anchory"] = y;
}
3. EUI Service initialization failed
Turn off ad blocker and proxy software
Egret Study Record