base on egret code lib