develop #10
@ -1,9 +1,8 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://Main.gdns" type="Script" id=1]
|
||||
[ext_resource path="res://levels/Level2.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://levels/Prototype.tscn" type="PackedScene" id=2]
|
||||
|
||||
[node name="Main" type="Node"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Level2" parent="." instance=ExtResource( 2 )]
|
||||
level = ExtResource( 2 )
|
||||
|
16
src/Main.cpp
16
src/Main.cpp
@ -9,6 +9,7 @@ void Main::_register_methods()
|
||||
{
|
||||
register_method("_ready", &Main::_ready);
|
||||
register_method("_physics_process", &Main::_physics_process);
|
||||
register_property<Main, Ref<PackedScene>>("level", &Main::set_level, &Main::get_level, NULL, GODOT_METHOD_RPC_MODE_DISABLED, GODOT_PROPERTY_USAGE_DEFAULT, GODOT_PROPERTY_HINT_RESOURCE_TYPE, String("PackedScene"));
|
||||
register_property<Main, bool>("full_screen", &Main::set_full_screen, &Main::get_full_screen, main::full_screen);
|
||||
register_property<Main, Vector2>("window_size", &Main::set_window_size, &Main::get_window_size, main::window_size);
|
||||
register_property<Main, int8_t>("launch_screen", &Main::set_launch_screen, &Main::get_launch_screen, main::launch_screen);
|
||||
@ -45,6 +46,11 @@ void Main::_ready()
|
||||
_os->get_screen_position(get_launch_screen()) + _os->get_screen_size() * 0.5 - _os->get_window_size() * 0.5
|
||||
);
|
||||
}
|
||||
|
||||
if (level != NULL)
|
||||
{
|
||||
add_child(level->instance());
|
||||
}
|
||||
}
|
||||
|
||||
void Main::_physics_process(float delta)
|
||||
@ -55,6 +61,16 @@ void Main::_physics_process(float delta)
|
||||
}
|
||||
}
|
||||
|
||||
void Main::set_level(Ref<PackedScene> level)
|
||||
{
|
||||
this->level = level;
|
||||
}
|
||||
|
||||
Ref<PackedScene> Main::get_level()
|
||||
{
|
||||
return this->level;
|
||||
}
|
||||
|
||||
void Main::set_full_screen(bool full_screen)
|
||||
{
|
||||
this->full_screen = full_screen;
|
||||
|
21
src/Main.h
21
src/Main.h
@ -5,6 +5,8 @@
|
||||
#include <Node.hpp>
|
||||
#include <OS.hpp>
|
||||
#include <Input.hpp>
|
||||
#include <PackedScene.hpp>
|
||||
#include <Ref.hpp>
|
||||
|
||||
/**
|
||||
* @brief This is the godot namespace for all the code included in the library.
|
||||
@ -57,6 +59,11 @@ namespace godot
|
||||
*/
|
||||
Input *_input;
|
||||
|
||||
/**
|
||||
* @brief The first level to load
|
||||
*
|
||||
*/
|
||||
Ref<PackedScene> level;
|
||||
/**
|
||||
* @brief If the window is full screen or not.
|
||||
*
|
||||
@ -116,6 +123,20 @@ namespace godot
|
||||
*/
|
||||
void _physics_process(float delta);
|
||||
|
||||
/**
|
||||
* @brief Set the level object.
|
||||
*
|
||||
* @param[in] level The new level to load when starting.
|
||||
*/
|
||||
void set_level(Ref<PackedScene> level);
|
||||
|
||||
/**
|
||||
* @brief Get the level object.
|
||||
*
|
||||
* @return Ref<PackedScene> The level scene to load.
|
||||
*/
|
||||
Ref<PackedScene> get_level();
|
||||
|
||||
/**
|
||||
* @brief Set the full screen object.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user