Giter Club home page Giter Club logo

egret-core's Introduction

forks stars version license

EN / CN

Egret Engine

The Egret Engine is a HTML5 game engine. It provides modules to handle common game development tasks such as 2D and 3D rendering, GUI systems, and audio and resource management. The Egret engine is flexible and suitable for 2D or 3D projects. It allows developers to work without worrying about low-level browser impelementation, HTML5 performance, or fragmentation issues.

Platform Coverage

Mobile

PC

Installation

To Install the Egret Engine:

Once installation is complete, Egret's engine and tools are easy to manage.

Getting Started

TypeScript

Egret projects are developed using TypeScript, which is a superset of JavaScript. Please refer to the TypeScript manual for more information. The Egret API and ActionScript3 (AS3) are very similar. It will be easy to get started with Egret if you are familiar with AS3.

Create a project by command line

Use following command to create a default game object:

egret create HelloWorld

You may also add parameters if required: Use empty | game | gui | eui to specify different projects.

After running this command, you should now see a folder called 'HelloWorld'.

Write your first line of code

By default, the entry point for an Egret game projects is src / Main.ts. To make write the first line of code for your project, find the createGameScene () function, and add console.log ("Hello World");

After making your changes, the code should now look like this:

private createGameScene():void {
        // log
        console.log("Hello World");
        var sky:egret.Bitmap = this.createBitmapByName("bgImage");
        this.addChild(sky);
        var stageW:number = this.stage.stageWidth;
        var stageH:number = this.stage.stageHeight;
        sky.width = stageW;
        sky.height = stageH;
        //...
    }

Here, we've called console.log("log content that we'd like to display"). This will display our log message in the browser's developer tool.

We recommend using Chrome to debug the Egret project.

Use the following command to build Egret projects:

egret build

Use the following command to run Egret projects:

egret startserver

For more information, please refer to the Learning Module documentation.

Demos

Tower Defence Demo Click here for online experience.

Click here for more 2D/3D demos.

Show Case

Click here to see Show Case

Learn

  • Access Doc to get Engine document
  • Access Example to learn demo source code
  • Access API to get API document
  • Access Video to get videos
  • Access Community to communicate with other developers

Tools

Third Party Library

  • Use base64texture to convert base64 String to egert Texture
  • Use dcagent DataEye SDK for Egret
  • Use ecs component system
  • Use euiextension EUI extension
  • Use gesture Gesture library
  • Use keyboard Keyboard event listener
  • Use Greensock Greensock animation library
  • Use jszip jszip Compression library
  • Use md5 A simple MD5 Library
  • Use mouse PC mouse support library
  • Use particle particle system
  • Use physics p2Physics engine,current version 0.7.0
  • Use socket socket.io
  • Use tiled tiledmap support library
  • Use weixinapi WeChat API
  • More third party libraries please visit here

Contributing

Asking a question is the first step to participating in an open-source community. You can report Egret issues here. It is recommended that issues be discussed in the official community portal, as it can help with solving problems efficiently.

License

This content is released under the (https://opensource.org/licenses/BSD-2-Clause) BSD License.

egret-core's People

Contributors

982049377 avatar akdcl avatar d8q8 avatar domchen avatar eos3tion avatar f111fei avatar himuil avatar imzc avatar jackyanjiaqi avatar jkd2972 avatar lijianegret avatar mebiusashan avatar necroneco avatar neoguo avatar quietrain avatar rockyf avatar runinspring avatar shawn0326 avatar shawnli-bj avatar sucresk avatar superlancelot avatar wanderwang avatar webreldesigner avatar wibrst avatar xrdavies avatar xsstomy avatar yanghanggit avatar yjtx avatar zerlot avatar zrong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

egret-core's Issues

请问TextField如何调用自定义ttf字体

发现你们引擎并没有提供加载远程ttf或者直接解析ttf或者其他字体格式的方法。
那么就有个问题,我使用TextField去渲染一个自定义字体的时候,如何知道该字体是否存在,或者该字体是否加载完成?有没有一个解决方案?

还有几个问题

1.使用this.relativeAnchorPointX = 0.5;this.relativeAnchorPointY = 0.5定位到中心,如果图片尺寸是奇数,就会变的模糊
2.属性里没有width和height。要用getBounds().height获得,有点麻烦
3.移除对象removeChild()以后,不再使用了怎么从内存里清除?=null就可以了吗?
4.SimpleButton好像有问题,我试了几次也没创建成功,setFontText 会出2行字

卸载 Egret 1.5.5 时卡住

操作系统:win7 64位旗舰版
Egret 版本: 1.5.5

卸载 Egret 时遭遇假死,查看进程 EgretAppManager 和 EgretScriptManager,然后统统关掉。在

C:\Users\youname\AppData\Roaming\Egret\script\Error.txt

中发现原因是无法覆盖 Adobe AIR.dll 文件。

几经周折,在 command.txt 文件中发现了这么一行:

run "bin/wscript.exe" "C:\Users\youname\AppData\Roaming\EgretAppManager\Local Store\uninstall.vbs"

估计是跟卸载脚本有关,于是双击之。于是神奇的一幕出现了,桌面的 Egret Engine 图标消失了。然后其他的几个程序也都好卸载了。

在此感谢 3 群 egret-xsstomy 大大和他同事们的帮助。

刚刚安装更新了最新版本,运行命令出错

localhost:demo1 mebius$ egret

module.js:340
throw err;
^
Error: Cannot find module 'file'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/usr/local/lib/node_modules/egret/tools/lib/tools/help.js:3:12)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
localhost:demo1 mebius$ egret help

module.js:340
throw err;
^
Error: Cannot find module 'file'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/usr/local/lib/node_modules/egret/tools/lib/tools/help.js:3:12)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)

ScrollView总是报warning

官方的模板output/examples 演示ScrollView的时候 console总是会输出
[Warning]target没有正在执行tween:
我自己写的也会报这个

Mac 下IOS打包出现的问题

os x 10.10
在线的开发版本
打包之后原来的工程无法运行,原来的代码不一样,缺少了一些代码。
IOS生成以后触摸的位置错位。在Ipad4真机上测试。

No error exception when run "node build_typescript.js" without typescript install

No error exception when run "node build_typescript.js" without typescript install, the bash console still display "[success]xxxxx".
This will cause developer confused if they forget to install typescript module at first.

如果开发者不安装typescript模块,而直接去使用“node build_typescrpt.js"命令,会仍然看到所有ts文件的“[success]”提示。这会让他们困惑,正确结果应该有error提示。

egret_loader.js中soundContext有误

在项目模板的egret_loader.js中,设置的是:
context.soundContext = new ns_egret.SoundContext();
这会导致声音无法播放,应该是:
context.soundContext = new ns_egret.HTML5SoundContext();

egret和bat脚本兼容有问题

bat中执行以下脚本:

egret publish
pause

在egret命令执行完之后bat即被杀掉,后面的pause根本没有机会执行。也就是说无法用egret顺畅的组成脚本管线,一旦遇到egret就会被掐断。

resource.json groups中的内容需要拆成多行

groups中的内容最好采用多行记录,方便团队多人同时工作,对版本管理工具更友好。现在超长的单行记录几乎每次都会冲突,几乎无法合并,几乎总要有人重复再做一次。
如果考虑运行时效率,可以在最终发布脚本中做紧缩合并。

几个问题

1.移除所有子对象flash里是removeChildren();egret是removeAllChildren();
我开始还以为没这个方法,建议和flash保持一致
2.ns_egret.Ticker.getInstance().register(function (advancedTime) {
dragonBones.animation.WorldClock.clock.advanceTime(advancedTime / 1000);
}, this);
register以后,我看源代码里有unregiseter,但好像不起作用
3.建议官方一个Sprite,我自己写了一个,简单继承DisplayObjectContainer就行。要不每次敲DisplayObjectContainer这个太长了
4.SpriteSheet要使用json文件,用起来不方便。可不可以增加starling格式的xml支持,有个air做的小工具叫shoebox,打包材质很方便。flashIDE即便有插件支持输出json,单为了打包材质也太占系统资源

Event.ADD_TO_STAGE在特定情况下会重复抛出

在以下代码中,当前版本 egret 存在问题


var stage = egret.MainContext.instance.stage;
var container = new egret.DisplayObjectContainer();
container.addEventListener(egret.Event.ADD_TO_STAGE,this.onAddToStage,this);


function onAddToStage(e:egret.Event):void {

        var container2 = new egret.DisplayObjectContainer();
        container2.addEventListener(egret.Event.ADD_TO_STAGE,this.onContainerAddToStage,this);
        container.addChild(container2);
}

function onContainerAddToStage(e:egret.Event):void {
        //这个方法会被执行两次
}

dragonbone完善回调

a2

egret 带有第三个参数thisObj,complete的时候可以apply
但是dragonbone没有这个参数,回调函数基本就没用,希望能完善一下

ns_egret能不能把ns_去掉啊

ns_egret能不能把ns_去掉啊,保留egret就够了吧,感觉每次都要加ns_,尤其是那个_,好蛋疼啊。。。。

java版本判断优化

publish.js里面这个改是否更合适:

ClosureCompiler.testJava = function (java, callback) {
    child_process.exec('"' + java + '" -version', {}, function (error, stdout, stderr) {
        stderr += "";
        var minVersion = 1.7;
        var currentVersion = 0;
        var re = /version \"\d.\d./gi;
        if(re.test(stderr)) {
            re = /\d.\d/gi;
            var arr = re.exec(stderr);
            currentVersion = arr[0];
        }
        if (currentVersion>=minVersion) {
            callback(true, null);
        } else if (stderr.indexOf("version \"") >= 0) {
            callback(false, new Error("Need Java "+minVersion+" but current version is "+currentVersion));
        } else {
            callback(false, error);
        }
    });
};

[QUESTION]类的显示成员变量在函数内无法获得x属性

class MyScene extends  ns_egret.DisplayObjectContainer {
       private _ball:ns_egret.Bitmap;
       private initTouchEvent():void {
        context.stage.addEventListener(ns_egret.TouchEvent.TOUCH_BEGAN,                   this.onTouchBeganHandler);
       }
       private onTouchBeganHandler(name, touch):void {
            console.log(this._ball.x);
       }

上面这样的代码(中间有省略一部分创建_ball的过程)。我监听了TOUCH_BEGAN事件,并且进入了回调函数,但回调函数里我无法获取到_ball.x属性。控制台出现如下错误:
Uncaught TypeError: Cannot read property 'x' of undefined
请问下这个正常么?

为什么编译生成的game_file_list.js中文件顺序是错的呢?

编译出来的game_file_list.js内容如下:

var game_file_list = [
...
"Main.js",
"libs/net/http/Http.js",
...
];

Main中使用Http类,运行的时候会报错,

Uncaught ReferenceError: Http is not defined

我看浏览器的加载顺序,Http.js会在Main.js之后才加载,所以才找不到Http这个类,
怎么控制game_file_list文件顺序呢?

bug for URLLoader

1.how to add custom header in URLRequest?
2.how to load AJAX JSON with header X-Requested-With:XMLHttpRequest

什么时候支持linux?

现在手动把egret目录提取出来,加了环境变量,然后发现build完了不能运行,egret的文件没有加载出来,看了半天源码发现 egret/tools/lib/tools/compile.js里第504行有一句:
var tsFile = file.joinPath(moduleConfig.prefix, moduleConfig.source, item).toLowerCase();

这句把源码文件路径转成了小写,linux是区分大小写的,所以后面没读到文件内容,结果所有文件都被当成了只含接口,没有加到egret_file_list.js里去。去掉.toLowerCase()后就正常了。

粗略看了一下还有好多地方都是这样用的,不知道还有没有需要改的。

以后打算支持linux吗?

build命令一个不完善的地方

当用户使用Create命令创建项目后,用户项目目录中会默认创建一个名称为launcher的文件夹,该文件夹内包含一些可以启动运行的html,javaScript文件。
当用户删除该文件夹后,使用build命令编译时候会提示用户,项目路径下应该包含launcher和src目录。
但是当用户手动创建一个空的launcher文件夹后,build命令可以正常执行。但是执行后,launcher目录中没有产生任何文件。此时启动server后,可以正常启动服务器,但是网页会无法找到文件。希望Build命令可以对这种情况进行处理!

谁有Typescript的相关书籍!小白苦等

对html5游戏开发的向往!一直想尝试却不知道从何做起!我是个php程序员,对web开发有一定的经验如今想转行做游戏开发,希望能得到大婶们的帮助,Erget新兴的游戏引擎,我肯定只要我坚持不放弃,一定可以让我在html5的道路上杀出一条血路!!希望好心的大大们能指点迷津能发点资料给我推我一把在此贴上邮箱地址[email protected]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.