Egret Study Record

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.