Well hot-loading is sort of not an entry level thing, per se, but itās not difficult, just probably not what Iād start with - go make a few fun silly small games first
Also, if you are using Creator then Javascript mitigates some of this since the entire game is scripted and doesnāt need to be recompiled. I do wish, however, that they added more update at run-time capabilities (maybe the latest version has improved in this area).
Hot-reloading that Iāve used personally is resources/data only, not c/c++ recompiling on the fly (though that is also possible). So either the game code watches for file change notifications, or polls files for changes, or has UI to force reload of object(s).
The data is reloaded from file (āentity_typename.dataā) into the entity typeās ātemplateā of sorts (for those created in future) and applied across all current entity instances in the scene of that type. Various resources are referenced in this template: sounds, animation frames, textures, etc.
So at a high-level the texture is swapped, base property values are updated (each instance can apply modifier values to these), some other properties are updated in whole (overwritten), new animation frame sets are swapped with old, etc.
Iāve added videos from handmade hero and j.blowās Jai development for some current examples.
(sorry the rest is quite long, I should probably move this onto my blog and link)
====================================================
If I started a new game (medium to larger, year+ long project) Iād want to start with some of these things right up front.
- Hot reloading of data (maps, entity, localization, etc)
- Heavily data-driven (again while scripting makes things easier initially, just making all data/properties modifiable without re-compiling gets you 80-90% of what scripting provides in most cases Iāve worked with where Lua/JS was used)
- In-Game UI to modify data/properties/scene as well that allows save/load (and versioning)
- Quake-style console either hooked up to CCConsole commands, or written from scratch (or open source code)
====================================================
Handmade Hero Hot-Recompile in C99 (but c++ compiler for a few extra features)
For a look at how one can in fact do hot-reload of actual code while debugging (or technically in released build on platforms where executing data is allowed) you can check out handmade heroās videos:
https://hero.handmade.network/episode/code/day022.
I think if you look at week 5 on this link those videos may also have some notes.
https://hero.handmade.network/episodes.
Note: I really donāt recommend this for anyone using cocos2d-x. If you really wanted this with c++ go use Unreal instead.
However, in general I do believe people think scripting languages are some golden ticket when in fact they really just wanted data files and an in-game editor with hot-reloading of these assets. An external editor can be used, but if you use an in-game editor with save/load then you donāt need the actual live reloading, for the most part.
====================================================
Coincidentally Jonathan Blow just did some streams on this exact very subject (see below). He doesnāt go into the platform layer file notification, but you can use libfswatch (https://github.com/emcrisostomo/fswatch) to hook up the capability. He also develops the console using immediate mode GUI ideas. You could use imGUI to use similar code, but otherwise youād have to figure out how to best apply the state onto the cocos::ui::Widgets if you use them for the quake console.
One key aspect Iāve found makes this easier with cocos2d-x is that we have game entity state separated from the Node* derived rendering instances. We update the Node* (et al) properties (position, sprite frame, etc) from the state. This means we only use Actions for menus and effects (particles, etc), but we do use the internal tween:: functions.
Cocos2d-x has a highly coupled data design, especially if you use Actions and such for manipulating state. We manually update spriteFrames for our animations by keeping frame index and anything else we need to set current sprite frame, for example. This allows us to hot-reload the prefix/frame-index-list and have a character on screen change to use the new animation texture/frames associated with the current running state (e.g. āwalkingā).
Quake Console
Cocos2d-x does have a limited console-like experience that can be used by telnetting into the game remotely. You can see the implementation in CCConsole.cpp
Archived Twitch Stream Videos
Disclaimer Notes:
- These are long and unedited archives of him live streaming on Twitch
- I wouldnāt watch straight through unless you were very interested in his new language
- Heās mostly streaming to show his progress on his new programming language JAI
- He does a little C++ here and there when heās debugging his JAI compiler
Hot-Reload Global State - variables, in his terms, you can extrapolate this out to loading data into a game entity
https://www.youtube.com/watch?v=Fl3CV7L6faQ&list=PLmV5I2fxaiCI9IAdFmGChKbIbenqRMi6Z&index=4 .
Initial Quake Console UI (6 parts - mostly again Iād expect it to be uninteresting for you)
https://www.youtube.com/watch?v=jjTzVMq_M3M&list=PLmV5I2fxaiCI9IAdFmGChKbIbenqRMi6Z&index=6 .
Adding simple Commands
https://www.youtube.com/watch?v=N2UdveBwWY4&list=PLmV5I2fxaiCI9IAdFmGChKbIbenqRMi6Z&index=7 .
Playlist where these exist (some others)
https://www.youtube.com/playlist?list=PLmV5I2fxaiCI9IAdFmGChKbIbenqRMi6Z .