mirror of
https://github.com/zoriya/My3D.git
synced 2026-06-07 20:21:06 +00:00
Adding a quit button
This commit is contained in:
+2
-1
@@ -12,4 +12,5 @@
|
||||
|
||||
int start_game();
|
||||
|
||||
void start_button(gc_engine *engine, int entity_id);
|
||||
bool start_button(gc_engine *engine, int entity_id);
|
||||
bool quit(gc_engine *engine, int entity_id);
|
||||
+1
-1
Submodule lib/gamacon updated: 5ed8d1d36b...334073ea43
@@ -5,8 +5,9 @@
|
||||
<font src="assets/fonts/roboto.ttf" />
|
||||
</data>
|
||||
<gc_entities>
|
||||
<panel src="panel" x="50%" y="40%" width="300" height="50%"/>
|
||||
<panel src="panel" x="50%" y="40%" width="300" height="55%"/>
|
||||
<text text="DPR tycoon" x="50%" y="25%"/>
|
||||
<button text="Start Game" x="50%" y="50%" click="start_button" color="black" />
|
||||
<button text="Quit game" x="50%" y="60%" click="quit" color="black" />
|
||||
</gc_entities>
|
||||
</gc_scene>
|
||||
@@ -13,6 +13,7 @@ int register_customcmps(gc_engine *engine)
|
||||
{
|
||||
engine->finish_physics(engine);
|
||||
engine->add_callback(engine, "start_button", &start_button);
|
||||
engine->add_callback(engine, "quit", &quit);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
+8
-1
@@ -6,7 +6,7 @@
|
||||
#include "scene.h"
|
||||
#include "my.h"
|
||||
|
||||
void start_button(gc_engine *engine, int entity_id)
|
||||
bool start_button(gc_engine *engine, int entity_id)
|
||||
{
|
||||
gc_scene *scene = scene_create(engine, "prefabs/game.gcprefab");
|
||||
if (!scene) {
|
||||
@@ -14,4 +14,11 @@ void start_button(gc_engine *engine, int entity_id)
|
||||
my_printf("The game scene couldn't be found.\n");
|
||||
}
|
||||
engine->change_scene(engine, scene);
|
||||
return (true);
|
||||
}
|
||||
|
||||
bool quit(gc_engine *engine, int entity_id)
|
||||
{
|
||||
engine->should_close = true;
|
||||
return (true);
|
||||
}
|
||||
Reference in New Issue
Block a user