Code Monkey home page Code Monkey logo

cocos / cocos-engine Goto Github PK

View Code? Open in Web Editor NEW
5.3K 130.0 1.5K 340.6 MB

Cocos simplifies game creation and distribution with Cocos Creator, a free, open-source, cross-platform game engine. Empowering millions of developers to create high-performance, engaging 2D/3D games and instant web entertainment.

Home Page: https://www.cocos.com/en/creator

License: Other

JavaScript 6.87% TypeScript 35.22% CSS 0.03% CMake 0.59% C++ 50.03% C 1.75% Objective-C 0.41% Objective-C++ 1.79% Java 1.67% Python 0.65% Shell 0.03% PEG.js 0.03% Makefile 0.01% EJS 0.12% SWIG 0.54% GLSL 0.25% Batchfile 0.01%
cocos cocoscreator game-engine game-development open-source gamedev engine vulkan metal mit-license

cocos-engine's Introduction

Cocos Creator Logo

stars forks license twitter

Engine for Cocos Creator

Cocos Creator is the new generation of game development tool in Cocos family, it brings a complete set of 3D and 2D features while providing an intuitive, low cost and collaboration friendly workflow to game developers. Cocos Engine is the runtime framework for Cocos Creator editor.

image

Cocos Creator inherited many good qualities and cool features from its previous versions, such as high performance low level C++ implementation, intuitive editor, cross-platform support. It supports native platforms, web platforms and rapidly expanding instant gaming platforms, including Windows, Mac, iOS, Android, HarmonyOS, Web, Facebook Instant Games, WeChat Mini Game and TikTok Mini Games.

Furthermore, Cocos Creator has pushed the engine technology to a whole new level for high performance with scalability on various platforms, full extensibility and easy development.

  1. Modern Graphics: The GFX implementation is designed to adapt to the modern graphics APIs, it uses Vulkan on Windows and Android, Metal on Mac OS and iOS, WebGL on Web platform.
  2. High Performance: The runtime engine is built with half C++ and half TypeScript, low level infrastructure, native platform adaptation, renderer and scene management are all written in C++ to ensure high runtime performance. We continue to move heavy lifting work to native as much as possible.
  3. Customizable Render Pipeline: The render pipeline is designed to be fully customizable, it has supported the builtin forward and deferred render pipeline across all platforms. Developers can customize their own render pipeline following the same approach.
  4. Extensible Surface Shader: The material system is built on Cocos effect format which uses GLSL 300, the shader programs will be converted to suitable runtime format automatically. The surface shader permit to fully customize the surface material while ensuring universal lighting model.
  5. Physically Based Rendering (PBR): The standard effect adopts physically based rendering, along with the physically based camera and the lighting based on physical metrics, developers can easily achieve realistic and seamless rendering results across different environment.
  6. Easy TypeScript API: The user level API set is provided in TypeScript, along with the powerful VSCode editor, development with Cocos Creator is incredibly efficient.

Besides all these highlights, Cocos Creator also provides builtin animation system, physics system, particle system, terrain editing support, complex UI system, instant preview etc.

image

This open source repository is the runtime engine of Cocos Creator, the engine is naturally integrated within Cocos Creator, designed to only be the essential runtime library and not to be used independently.

Development and Contribution Notice

Cocos Creator engine is open source and welcomes community participation, for open source engine development with Cocos Creator editor, you should fork this repository and setup custom engine in the editor.

Prerequisite

Clone

Clone this repository into your local environment.

Install

In the cloned engine folder, run the following command to setup development environment:

# download & build engine dependencies
npm install

This is all you have to do to setup engine development environment.

Build

  • If running inside Cocos Creator, the engine will automatically compile and build after the editor window is opened. For more instructions on modifying the engine in Cocos Creator, please refer to Engine Customization Workflow.
  • Outside the editor, you need to run the following command to build:
npm run build

Please refer to native readme if you want to develop native applications.

Contribution

You can contribute to the Cocos Creator open source engine in many ways, they are very much appreciated:

  1. Report bug or feature requests by creating an issue.
  2. Participate discussions in the issues.
  3. Create a pull request if you have fixed or improved anything, implemented any features.
  4. Improve the documentations with pull request to the usage documentation repository.
  5. Help other developers in our Forum.

Contribution notice

If you are trying to make a pull request, there are some requirements that must be met so that your pull request can be accepted:

  1. Follow our Cpp Coding Style Guide and TypeScript Coding Style Reference.
  2. Try to integrate ESLint and CPP auto fix tools in your coding environment.
  3. Link related issues or discussions in your pull request and clearly state the purpose of your pull request.
  4. Pass all automatic continuous integration tests.
  5. Request file owner or engine developers to review your pull request.
  6. Get one valid approval from the engine architects.

Example Project

  • Mind Your Step 3D: Beginner's step-by-step tutorial project repo.
  • Test Cases: Unit test scenes for every engine module.
  • Example Cases: Simple yet expressive demo scenes for baseline testing and topic-specific case study.
  • Awesome Cocos: You can find out other useful tools and show cases here.

Links

cocos-engine's People

Contributors

2youyou2 avatar arsen2010 avatar bofeng-song avatar caryliu1999 avatar cocos-robot avatar cocosrobot avatar dabingnn avatar dumganhar avatar hana-alice avatar holycanvas avatar jareguo avatar jaycelai avatar jerrywwl avatar jk20012001 avatar jonelau avatar knoxhuang avatar linyunmo avatar minggo avatar mmyduckx avatar nantas avatar pandamicro avatar patricejiang avatar pppro avatar shrinktofit avatar star-e avatar troublemaker52025 avatar visualsj avatar wenhailin avatar yunhsiao avatar zilongshanren 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

cocos-engine's Issues

关于CCComponentEventHandler的一些问题

我在使用cocos-creater的时候,也想用到CCComponentEventHandler一样的效果,就是第一个属性选择了之后,根据第一个属性列出可以选择的第二个属性,选择了第二个属性之后,根据第二个属性列出可以选择的第三个属性,但是看了代码,好像并没有给出如何操作的,我尝试用notify来改动属性的值,也没有成功,请问有什么办法吗?

Wrong compiling project in CocosCreator for Mac (for simulator and browser)

Hello! I don't know if this issue is engine related, btw I can't find cocos creator repository for reporting this bug.

So, my game project is pretty big and yesterday I noticed very destructive bug in cocos creator for MacOSX.

When I try to recompile scripts I get the error:

SyntaxError: Unexpected token }

I'm sure that my scripts are valid. The project can be compiled and ran successfully in cocos creator for windows, the problem exists only for mac.

So, when I tried to run project in simulator I get this error message:

Simulator: SyntaxError: syntax error
at a (/Volumes/Transcend/projects/fluffy-dances-dev/fluffy-dances/library/bundle.project.js?009:7533:0)

When I inspect the bundle.project.js file I see that it has invalid syntax:

2016-09-16 11 36 52

As you can see the RemovablePattern module starts in the line which is commented out. This is line

//# sourceMappingURL=data:application/json;charset=utf-8;base64,blablabla

I can find several places in file bundle.project.js where the code is corrupted by the same way. For example, one more broken module:

2016-09-16 11 42 00

I uploaded the full bundle.project.js file to dropbox

When I run the project in browser I get the same problem:

2016-09-16 11 50 37

So, the main question is: how can I disable generating source maps at all? I don't need them for debugging.

Probably TileMap rendering bug

I encounter an exception at design- and runtime while trying to render TileMap.

My .tmx file uses one tileset, which consists of two separate images.
But in runtime only one image gets loaded. (Network tab)

Error Callstack
screen shot 2016-04-16 at 17 53 24

It seems like the engine does not handle case, when tileset is composed of several separate images.
Because it tries to use the first tile image with "displaced" rect ({ x: 0, y: 50, width: 50, height: 50 })

May be i miss something, but there is an error nonetheless.
Here is a Creator project with the bug

I use Cocos Creator v1.0.1

Would appreciate any help, thanks!

p.s.: Great project you are doing, keep going!

base-node里面的detachChild方法的parent使用有问题。

  _detachChild: function (child, doCleanup) {
        // IMPORTANT:
        //  - 1st do onExit
        //  - 2nd cleanup
        //if (this._running) {
        //    child.onExitTransitionDidStart();
        //    child.onExit();
        //}

        // If you don't do cleanup, the child's actions will not get removed and the
        if (doCleanup)
            child.cleanup();

        child.parent = null;
        cc.js.array.remove(this._children, child);
        this.emit(CHILD_REMOVED, child);
    },

以前的child.parent=null只是一个单纯的属性赋值,现在却变成了一个方法调用。

@pandamicro 这个有问题。

Particles are not copied when building for Web Desktop

Hello,

I built a small project with Cocos Creator. And when i tried to build it for web desktop i found out that not all assets get copied. I have a .plist and .png under assets/particles, but they are absent in build directory.

When i copy them to the build directory under build/web-desktop/res/raw-assets/particles/ everything works as expected.

將騰訊開發的tutorial blackjack在Android Device運行問題

我有將騰訊開發的tutorial blackjack以cocos creator1.3.2與1.3.3編輯,這遊戲在html5 web與ios都可以跑,但是在Android device上面執行(我是用htc 728測試),在主畫面點擊button...就會crash 閃退(但是在Android 模擬器又可以順利執行),用Logcat也看不到明確的錯誤log出來,這是何解啊~!? 有人有這情況嗎? 由於cocos creator是我們公司2017年開發項目的主義技術依據,麻煩各位大大給點意見~

How to run cocos-creator engine locally

Hi there,

I followed the direction on this github engine repository

I was able to build the engine but I do not how to run the server --> (Start a http server in cloned project folder). Please tell me which command to use? I am on Windows 7, 32BIT

I have tried all possible node XXXX.js I could think off
Many thanks!

God blesses!!!

Best regards,
Sanyaade

Multiple keyframes on the same frame

Sometimes I end up with multiple keyframes on the same frame. I can confirm this by opening the .anim file in a text editor. The timeline and properties panel behave erratically when this happens.

One way to reproduce it is to move one keyframe over another in the timeline editor. The expected behaviour is to overwrite the keyframe value.

Reproducible in 1.3 beta.

接电话后返回游戏声音没有

接电话后,以下事件无响应,导致游戏声音无法恢复
cc.game.EVENT_HIDE
cc.game.EVENT_SHOW
此时,就算重新使用cc.audioEngine.playMusic()也无法再次播放声音。

how to define a common Class in a file?

我在查看文档http://www.cocos.com/docs/creator/scripting/class.html的时候,遇到一个问题。
下面是文档中的代码demo。
var Shape = cc.Class({
ctor: function () {
cc.log("Shape"); // 实例化时,父构造函数会自动调用,
}
});

var Square = cc.Class({
extends: Shape,
ctor: function () {
cc.log("Square"); // 再调用子构造函数
}
});

var square = new Square();
//以上代码将依次输出 "Shape" 和 "Square"。

//如果把上面的代码拆分成2个文件后调用,
//Shape.js
cc.Class({
ctor: function () {
cc.log("Shape"); // 实例化时,父构造函数会自动调用,
}
});

//Square.js
var Shape = require('Shape');
cc.Class({
extends: Shape,
ctor: function () {
cc.log("Square"); // 再调用子构造函数
}
});

//helloworld.js中调用
var Square = requir('Square');
var square = new Square();
//这个类会查询不到,然后报错。如果我现在让Shape类继承于cc.Component后,就可以了。
//Component 是特殊的 CCClass,不能定义构造函数,它的构造职能可由 onLoad 方法代替。我现在的初衷只是定义一个常见的类,不需要继承Component。

Feature Request: Code indentation setting

Hey,

I would like to say, that if there was a possibility to change code indentation for project scripts it would be awesome! (e.g.: spaces vs tabs; number of spaces)

p.s.: Just wondering if you accept feature requests and if it is good idea to do it via github issues.

Thanks!

Loader 内统一使用 url 缓存

因为现有两种缓存(url/uuid)公用会出现一些问题。
uuid的缓存后,使用url重新加载会造成判断缓存不存在,重新进行一次加载,造成重复的资源缓存。

所以需要统一缓存的索引形式。

dragonBone动画换肤在H5上表现正常, 在原生平台闪退

我们自己调查了下

https://github.com/cocos-creator/engine/blob/de1c6b174b6399f502cfe6280d64b9aebf3126f7/extensions/dragonbones/ArmatureDisplay.js#L323

调用的原生解析方法返回的是一个空对象,里面this._dragonBonesData.armatureNamesundefined

我们游戏中调用的代码片段

      this._armatureDisplay.armatureName = 'qiao';
      this._armatureDisplay.buildArmature('qiao');
      this._armatureDisplay.playAnimation('qiao', 1);

使用的dragonData 在 https://pan.baidu.com/s/1jHJAhIu

Build error JS_Parse_Error

Hello!
My project can be built successfully in Debug mode (for iOS and Android). But when I disable debug mode and try to build I get this error:

Build Failed: Error
at new JS_Parse_Error (eval at <anonymous> (/Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:1534:18)
at js_error (eval at <anonymous> (/Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:1542:11)
at croak (eval at <anonymous> (/Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2089:9)
at token_error (eval at <anonymous> (/Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2097:9)
at unexpected (eval at <anonymous> (/Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2103:9)
at semicolon (eval at <anonymous> (/Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2123:56)
at simple_statement (eval at <anonymous> (/Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2314:73)
at eval (eval at <anonymous> (/Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2183:19)
at eval (eval at <anonymous> (/Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2136:24)
at block_ (eval at <anonymous> (/Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/gulp-uglify/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2429:20)
at /Applications/CocosCreator.app/Contents/Resources/app.asar/editor/core/builder.js:1:1995
at /Applications/CocosCreator.app/Contents/Resources/app.asar/editor/core/builder.js:1:944
at Gulp.doneCallback (/Applications/CocosCreator.app/Contents/Resources/app.asar/editor/core/gulp-build.js:1:11735)
at Gulp.Orchestrator.stop (/Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/orchestrator/index.js:150:9)
at n (/Applications/CocosCreator.app/Contents/Resources/app.asar/editor/core/gulp-build.js:1:3990)
at Object.callback (/Applications/CocosCreator.app/Contents/Resources/app.asar/editor/core/gulp-build.js:1:5859)
at /Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/async/lib/async.js:906:35
at _arrayEach (/Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/async/lib/async.js:85:13)
at /Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/async/lib/async.js:898:17
at /Applications/CocosCreator.app/Contents/Resources/app.asar/node_modules/async/lib/async.js:44:16
at BrowserWindow.<anonymous> (/Applications/CocosCreator.app/Contents/Resources/app.asar/editor/core/compiler.js:1:1276)
at BrowserWindow.g (events.js:286:16)
at emitOne (events.js:101:20)
at BrowserWindow.emit (events.js:188:7)

As far as I see uglify-js should throw new JS_Parse_Error with additional information in what file and where it has troubles. But I not see this information in CocosCreator log. It shows me only the stack log but not the content of thrown exception.

Also I can't modify library js files in order to add more verbose output because app.asar seems not to be a valid asar file:

bash-3.2$ asar list app.asar 
buffer.js:615
    throw new RangeError('index out of range');
    ^

RangeError: index out of range
    at checkOffset (buffer.js:615:11)
    at Buffer.readUInt32LE (buffer.js:677:5)
    at Pickle.getPayloadSize (/usr/local/lib/node_modules/asar/node_modules/chromium-pickle-js/lib/pickle.js:192:24)
    at new PickleIterator (/usr/local/lib/node_modules/asar/node_modules/chromium-pickle-js/lib/pickle.js:27:28)
    at Pickle.createIterator (/usr/local/lib/node_modules/asar/node_modules/chromium-pickle-js/lib/pickle.js:144:12)
    at Object.module.exports.readArchiveHeaderSync (/usr/local/lib/node_modules/asar/lib/disk.js:91:31)
    at Object.module.exports.readFilesystemSync (/usr/local/lib/node_modules/asar/lib/disk.js:97:25)
    at Object.module.exports.listPackage (/usr/local/lib/node_modules/asar/lib/asar.js:174:15)
    at Command.<anonymous> (/usr/local/lib/node_modules/asar/bin/asar.js:42:27)
    at Command.listener (/usr/local/lib/node_modules/asar/node_modules/commander/index.js:301:8)

bash-3.2$ asar --version
v0.13.0

CocosCreator 1.3.3 for MacOS

Bug 1.3.2 安卓上 cc.game.restart()报错

4:36.458 3448 3464 D cocos2d-x debug info: Cocos2d-JS v3.13
11-28 18:44:38.453 3448 3464 E cocos js error:: /data/user/0/com.baiyou.dkd/files/blackjack-remote-asset/src/jsb_polyfill.js line:28901 msg:TypeError: cc.director.getScheduler(...)._schedule is not a function
11-28 18:44:38.454 3448 3464 D cocos2d-x debug info: Evaluating main.js failed (evaluatedOK == JS_FALSE)
11-28 18:48:59.072 1397 1461 I Timeline: Timeline: Activity_windows_visible id: ActivityRecord{e64af45 u0 com.baiyou.dkd/org.cocos2dx.javascript.AppActivity t3034} time:27741710
11-28 18:48:59.161 2481 16985 I AD-PLUGIN-SystemAdController: activityIdle:ActivityInfo{efc2c07 org.cocos2dx.javascript.AppActivity} mPendingSwitchingActivityInfo:null

A question.

I haven't understand if this is the full Cocos Studio Source or not.... Is a framework for scripting without the visual editor or is the the source of the engine and the source of the visual editor?
I ask this because i want to try to compile and understand how an editor is made, but if there isn't the editor i won't download the repo. Thanks!

CCScrollView on desktop web

CCScrollView is a little broken on desktop web. If you scroll using the mouse wheel, or with two-finger scroll on a touchpad, the result is both backwards and really slow.

For example, if Google Chrome would normally respond to the mouse wheel gesture by scrolling down about 40 pixels, a Cocos ScrollView will respond by scrolling up about 2 pixels.

I believe this can be fixed by changing CCScrollView.js line 702 from
var wheelPrecision = 1.0 / 40;
to
var wheelPrecision = -0.6;

Negative 0.6 feels about right, but see what you think.

Dockerfile

Hi guys,

Hope you are all well !

I was looking at your amazing work and I was wondering if a dockerfile was available with Alpine as a base image. It would be great for testing or launching latest version faster.

Thanks in advance.

Cheers,
Luc

Create packages for C++/JS bindings

Hi guys,

Hope you are all well !

I have a last question about about cocos-creator as I am quite new to your great tool; Is it possible to create a package of assets with a universal configuration file (like a plist) in order to execute a game created with your UI but launchable not only with the JS API but the C++ one also.

More precisely, I was thinking to use Vuforia/Artoolkit with cocos2d-x in order to create augmented reality interactions and to load different mini games per markers/images recognized and tracked.

I was wondering if cocos-creator could be a UI to build those interactions with ease.

Cheers,
Luc Michalski

Memory leaks or How to release a Scene

Hello!
I have made a very simple cocos creator project. Just four scenes which switches in a cyclic manner. Each scene has a huge background picture.

The switching code is also very simple:

cc.Class {
    extends: cc.Component

    properties: {
    }

    bntNext: (event, sceneName) ->
        #scene = cc.director._scene
        #scene.autoReleaseAssets = true
        cc.director.loadScene sceneName, 
            () ->
                cc.log sceneName, 'loaded'
            () ->
                cc.log 'current scene unloaded'
}

When I run the project (on iOS simulator or device) and switch between the scenes I have this memory usage graph:
2017-02-17 11 40 41

As you can see the scenes was loaded on demand (only once) and have never been released. All four scenes resources remain in the memory.

When I uncomment these lines

        scene = cc.director._scene
        scene.autoReleaseAssets = true

I get a much more strange effect:
2017-02-17 11 47 38
The scene doesn't release resources but every time it loaded them again and again.

I tried some magic with cc.loader.releaseAll() and cc.textureCache.removeAllTextures() but had no lucky at all.

So how can I release a scene with all it's resources?

Raw assets sets on property panel are inaccessible from code and potentially loaded twice

Hi,
I found a problem on the javascript engine related to assets management. Raw assets set on property panel are created automatically before the scene start but they cannot be accessed from code because cc.load.getRes doesn't find it even though the resource is present on cc.loader._cache.
Debugging a bit I found that cc.load.getRes fail because cc.loade._getResUuid(url) fail as well.
The problem is that the mapping from the raw assets url to Uuid is not being created when the resources is created automatically.
On cc.loader.resources.pathToUuid the mapping is not present and cc.loade._getResUuid(url) search on that structure for the mapping.

This problem cause that raw assets are loaded twice, once because the asset is created and load automatically and next time for instance cc.audioEngine.playEffect(clip) is called. This happen because playEffect relays on cc.load.getRes to find the clip, but due cc.load.getRes is failing, the resource es created and load again. So as a result cc.loader._cache has the same resource with different ids.

Exactly the same problem happens for texture2d set as a property, it's created automatically but it's inaccesible using cc.loader.getRes.

This is a new issue appeared recently because before of version V1.3.1 this worked properly.

Thanks

Touch.getStartLocation() is different at the end of a touch event

With the following code:

var startLocation;
cc.eventManager.addListener({
    event: cc.EventListener.TOUCH_ONE_BY_ONE,
        onTouchBegan: function(touch, event) {
            startLocation = touch.getStartLocation();
            return true; // required to consume event
        },
        onTouchMoved: function(touch, event) {
        },
        onTouchEnded: function(touch, event) {
            // this prints false
            console.log(touch.getStartLocation().x === startLocation.x);
        }
}, self.node);

Notice how touch.getStartLocation() is not equal to the location at the start of the touch. My guess is that it is no longer the OpenGL coordinates, though it's hard to tell where this issue is happening in the code.

1.4热更新模块有问题,每次启动会清掉storagepath下的数据。

1.4热更新模块有问题,每次启动会清掉storagepath下的数据。

1、storagepath和storagepath_temp里面都没有任何东西。
image
2、点击检查更新,在storagepath_temp路径下会出现version文件。
image
3、点击更新,storagepath_temp路径下的内容会被转移到sotargepath路径下。
image

现在说明整套更新流程是OK的,但是。当我重新允许应用的时候,整体被恢复了。
目录被重写生成,数据清空。 重复流程1、2、3。

android环境测试也是一样

Status of CCUI?

I've seen CCUI files are included in the repo and have some changes from upstream (e.g. usage of require()), but they are not linked in index.js for compilation.

Is CCUI supported in this fork? Is it planned, dropped or deprecated...? Is it usable already and maybe I'm missing something?

Regards.

Get loaded scene name

Hi, is this possible in cocos creator. I tried all ways to get loaded scene name but I could not achieve this problem.

cc.director.getScene() returns cc.Scenebut its "name" property is empty.

CCSGNodeCanvasRenderCmd updateColor not call

因为现在Node.WebGLRenderCmd是用到Node.CanvasRenderCmd中的 _syncStatus
cocos2dx-js的NodeWebGLRenderCmd中的_syncStatus不太一样

而CCSGNodeCanvasRenderCmd.js 中的 _syncStatus
if(colorDirty) this._updateColor();
这段应该是
if (colorDirty || opacityDirty) this._updateColor();

不好意思 我太会用github
如果有问题请移除

[Feature Request] ES6 Classes for inheritance.

It would be awesome if it was possible to use es6 classes for components.

class Enemy extends cc.Component {
  static properties = {
    maxHP: { default: 100, visible: true },
    restoreHPPerSec: 1,
  };

  onLoad() {
    // Props could be treat as immutable 
    const { maxHP } = this.props;
    // It is pretty handy to keep the whole state in one place as plain object
    this.state = {
      hp: maxHP,
      restoreHPTs: 0
    };
  }

  update(dt) {
    const { hp } = this.state;
    const { maxHP, restoreHPPerSec } = this.props;

    if (maxHP !== hp) {
      const now = Date.now();
      if (now - this.state.restoreHPTs >= 1000) {
        this.state.hp = Math.min(maxHP, hp + restoreHPPerSec);
        this.state.restoreHPTs = now;
      }
    }
  }
}

The code becomes more clean and thus more readable and imo conformance to the standard is a good idea.

I understand that it may be pretty hard to implement, since it leads to breaking changes. (now properties are spread directly to this). Not impossible though.

Script caching issue

Steps to reproduce:

  1. Create a new "Hello World" project
  2. Run the project in the simulator
  3. Edit text property in the file Script/HelloWorld.js and change it to something like "Hello, there!" instead of "Hello, world"
  4. Note that after refreshing the new text does not get rendered on the screen. The old "Hello, world!" text still persists.

Only after renaming the properties.text to something else (like test) then using this.test will the auto update grab the changes to the string.

The following is the output of the console:

Simulator : LOAD Js FILE: main.js
Simulator : Evaluating script/debugger/actors/script.js failed (evaluatedOK == JS_FALSE)
Simulator : /Applications/CocosCreator.app/Contents/Resources/cocos2d-x/simulator/mac/Simulator.app/Contents/Resources/script/debugger/actors/script.js:3139:ReferenceError: ObjectActor is not defined
Simulator : ScriptingCore::callFunctionName error:__errorHandler wasn't found!
Simulator : Cocos2d-JS v3.9
Simulator : iShow!

Mac OSX 10.9.5

getDuration of audioclips on JSB doesn't work, always returns -1

Hi guys,
when testing a cocoscreator app on the simulator or by building to windows, getDuration of audioClips always returns -1. This was tested on Release 1.3.2

Also in order to improve interface, now getDuration requires pass the cc.audioEngine's audioId as a parameter and to obtain the id, the audio mast be played before,
var id = cc.audioEngine.playEffect(sound);
var duration = cc.audioEngine.getDuration(id);

Most of the time is useful to get the duration only without play the clip, can the interface be improved to get the duration using the clip url and without play it before?

Thanks in advance.

Motion Streak with Follow action doesn’t work

I cloned the pool-physics-demo and change a bit to add a MotionStreak to the cue and have the scene follow it. But the MotionStreak won't render anything at runtime. If I use the mouse to move it around in the editor it will show properly (with Preview). And if I add the MotionStreak to other ball, it will show as normal. No, I take that back. It will show the streak, not when the ball move, but when the scene move (when the ball remains static).

What should I do to get it works?

image

In the picture, when I click, the cue jump up (no streak). The other ball stay static (but has streak).

cc.Sprite('')希望添加一下功能吧

Sprite(SpriteFrame|String newSpriteFrame) {
var node = new cc.Node("Sprite");
var sprite = node.addComponent(cc.Sprite);
sprite.spriteFrame = newSpriteFrame;
return sprite
}
cc.loader.loadxxx
var abc=cc.Sprite('abc');

希望添加这样的功能吧!不止Sprite。。。

能把creator.d.ts下的错误修改一下吗?

错误如下
export class RawAsset extends CCObject {
不知道CCObject和Object定义中的有什么区别

export function jumpBy(duration: number, position: Vec2|number, y?: number, height: number, jumps: number): ActionInterval;

dragonBones.xxx

ToggleGroup 能不能添加个属性

let group=cc.find('Canvas/ToggleGroup').getComponent(cc.ToggleGroup);
let count=group.node.childrenCount;//数据大小没有问题,内容有问题
let counta=group._toggleItems.length;
cc.log("count:"+count+"\t"+counta);
let index=group.node.children.indexOf(toggle);//目前还不知道这里面是什么东西
let indexa=group._toggleItems.indexOf(toggle);//这个内容是没有问题的
cc.log("index:"+index+"\t"+indexa);

假如ToggleGroup就添加一个事件,还想知道是哪个Toggle触发的事件
能不能把_toggleItems整出到外部,可以调用的API(类似于node. children)

No spaces allowed in project path?

A new project path of C:\Users\User Name\Documents\Cocos\NewProject gives an error of "Invalid project path, can only contains alphanumeric characters, - and _"

Does Cocos Creator support spaces in project paths?

cc.Node:getActionByTag returns undefined

Hi,
I'm working with actions and I can't get an action by its tag.
Here is a sample code:

var node = new cc.Node("New Node");
this.node.addChild(node);
var action = cc.moveTo(cc.p(100, 100));
action.setTag(1);
node.runAction(action);
// ...
node.getActionByTag(1); // returns undefined

When I looked at the code I realized a return statement is missing here:
https://github.com/cocos-creator/engine/blob/master/cocos2d/core/CCNode.js#L1420
I think it should be:

return cc.director.getActionManager().getActionByTag(tag, this);

Regards.

1.4rc1 new coffeescript component error

Error: ENOENT: no such file or directory, open 'E:\game_projects\test_21\library\imports\40\40d9b3e4-98ea-4d49-afbc-db44114d6f4a.js.map'
at Error (native)
at Object.fs.openSync (fs.js:640:18)
at Object.module.(anonymous function) [as openSync] (ELECTRON_ASAR.js:186:20)
at Object.fs.readFileSync (fs.js:508:33)
at Object.fs.readFileSync (ELECTRON_ASAR.js:523:29)
at getBabelSourceMaps (E:\ccc1.4_rc1\resources\app.asar\editor\page\refine-sourcemap.js:1:942)
at Stream.refineSourceMap (E:\ccc1.4_rc1\resources\app.asar\editor\page\refine-sourcemap.js:1:2260)
at Stream.stream.write (E:\ccc1.4_rc1\resources\app.asar\node_modules\through\index.js:26:11)
at write (E:\ccc1.4_rc1\resources\app.asar\node_modules\vinyl-buffer\node_modules\readable-stream\lib_stream_readable.js:623:24)
at flow (E:\ccc1.4_rc1\resources\app.asar\node_modules\vinyl-buffer\node_modules\readable-stream\lib_stream_readable.js:632:7)
at E:\ccc1.4_rc1\resources\app.asar\editor\core\compiler.js:1:1022
at E:\ccc1.4_rc1\resources\app.asar\editor\core\compiler.js:1:466
at BrowserWindow. (E:\ccc1.4_rc1\resources\app.asar\editor\core\compiler.js:1:2045)
at BrowserWindow.g (events.js:286:16)
at emitOne (events.js:101:20)
at BrowserWindow.emit (events.js:188:7)

simulator 调试的时候用 SocketIO.connect 报了 Microsoft Visual C++ .exe R6010 abort error

如题

image

CCC 1.3.0 console 信息:
image

代码如下:
(在谷歌浏览器下工作正常)
plugin:

(function (root) {
    // 绑定 dragon planet 的全局库
    let dp = {
        remote: {
            single: null,
            init: function (host) {
                if (cc.sys.isNative) {
                    this.single = root.io.connect(host)
                } else {
                    this.single = root.io(host)
                }
            }
        }
    }
    root.dp = dp
    if (cc.sys.isNative) {
        root.io = SocketIO
    } else if (typeof io === 'undefined') {
        root.io = require('socket.io-client')
    } else {
        root.io = io
    }

})(this)

Game.js

   dp.remote.init('ws://xxx:3000/star');

备注: sample 里的 network 代码是可以正常执行的

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.