当前位置:网站首页>Interpretation of Cocos creator source code: engine start and main loop

Interpretation of Cocos creator source code: engine start and main loop

2020-11-06 01:32:24 itread01

# Preface ## Preparation > I don't know if you ever thought about , If you compare the game world to a car , So this one “ Automobile ” How to start , How does it work continuously ? As the title , The main content of this paper is Cocos Creator Engine ** Start the process ** and ** The main loop **. And in the content of the main loop, there will be :** Component lifecycles and timers 、 Retarder system 、 Animation system and physical system, etc ...** ** This paper will interpret the relationship between the main loop and each module from the macro view **, The modules will also be introduced briefly , But it doesn't go deep into the specific implementation of the module . Because if you put every module “ feel ” Again , I'm afraid this article can't be finished . ## Go! I hope you can understand more after reading this article Cocos Creator engine . At the same time, I hope this article can play a role in “ Master leads in ” The role of , Let's cheer up and practice duck together ~ in addition 《 Original code interpretation 》 series ( It should be ) It will be updated continuously , If you want a skin to interpret a module of the interpretation engine , Also welcome to leave a message to tell me , I ... I'll think about it. Ha ha ~ * This article takes Cocos Creator 2.4.3 The version is for reference .* --- # Text ## Start the process ### index.html > For Web Platform index.html Archives are the absolute starting point . > In the preset index.html In Archives , Defines the layout of the game launch page , And there's a piece of code that runs immediately . Here we retrieve some of the more critical code in the file : ```javascript // Load engine script loadScript(debug ? 'cocos2d-js.js' : 'cocos2d-js-min.ec334.js', function () { // Whether the physical system is turned on ? if (CC_PHYSICS_BUILTIN || CC_PHYSICS_CANNON) { // Load the physical system script and start the engine loadScript(debug ? 'physics.js' : 'physics-min.js', window.boot); } else { // Start the engine window.boot(); } }); ``` The above code is mainly used to load engine script and physical system script , After the script is loaded, it calls main.js Defined in `window.boot()` Function . >

版权声明
本文为[itread01]所创,转载请带上原文链接,感谢