summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--demos/2d/platformer/moving_platform.pngbin0 -> 2143 bytes
-rw-r--r--demos/2d/platformer/moving_platform.xml119
-rw-r--r--scene/2d/tile_map.cpp21
-rw-r--r--scene/2d/tile_map.h7
4 files changed, 75 insertions, 72 deletions
diff --git a/demos/2d/platformer/moving_platform.png b/demos/2d/platformer/moving_platform.png
new file mode 100644
index 0000000000..f01c6ea37f
--- /dev/null
+++ b/demos/2d/platformer/moving_platform.png
Binary files differ
diff --git a/demos/2d/platformer/moving_platform.xml b/demos/2d/platformer/moving_platform.xml
index f39b11782c..4d54d6d11c 100644
--- a/demos/2d/platformer/moving_platform.xml
+++ b/demos/2d/platformer/moving_platform.xml
@@ -1,56 +1,77 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<resource_file type="PackedScene" subresource_count="3" version="1.0" version_name="Godot Engine v1.0.stable.custom_build">
- <ext_resource path="res://moving_platform.gd" type="Script"></ext_resource>
- <ext_resource path="res://tileset.xml" type="TileSet"></ext_resource>
+<resource_file type="PackedScene" subresource_count="4" version="1.0" version_name="Godot Engine v1.0.3917-beta1">
+ <ext_resource path="res://moving_platform.*" type="Texture"></ext_resource>
+ <ext_resource path="res://moving_platform.*" type="Script"></ext_resource>
+ <resource type="ConvexPolygonShape2D" path="local://1">
+ <real name="custom_solver_bias"> 0 </real>
+ <vector2_array name="points" len="4"> -88, 24, -88, -24, 88, -24, 88, 24 </vector2_array>
+
+ </resource>
<main_resource>
<dictionary name="_bundled" shared="false">
<string> "names" </string>
- <string_array len="28">
+ <string_array len="46">
<string> "moving_platform" </string>
<string> "Node2D" </string>
- <string> "_import_path" </string>
<string> "visibility/visible" </string>
<string> "visibility/opacity" </string>
<string> "visibility/self_opacity" </string>
+ <string> "visibility/on_top" </string>
<string> "transform/pos" </string>
<string> "transform/rot" </string>
<string> "transform/scale" </string>
- <string> "z/z" </string>
- <string> "z/relative" </string>
<string> "script/script" </string>
<string> "__meta__" </string>
<string> "motion" </string>
<string> "cycle" </string>
<string> "platform" </string>
- <string> "TileMap" </string>
+ <string> "RigidBody2D" </string>
+ <string> "shape_count" </string>
+ <string> "shapes/0/shape" </string>
+ <string> "shapes/0/transform" </string>
+ <string> "shapes/0/trigger" </string>
<string> "mode" </string>
- <string> "tile_set" </string>
- <string> "cell/size" </string>
- <string> "cell/quadrant_size" </string>
- <string> "cell/custom_transform" </string>
- <string> "cell/half_offset" </string>
- <string> "collision/body_mode" </string>
- <string> "collision/friction" </string>
- <string> "collision/bounce" </string>
- <string> "collision/layers" </string>
- <string> "tile_data" </string>
+ <string> "mass" </string>
+ <string> "friction" </string>
+ <string> "bounce" </string>
+ <string> "custom_integrator" </string>
+ <string> "continuous_cd" </string>
+ <string> "contacts_reported" </string>
+ <string> "contact_monitor" </string>
+ <string> "active" </string>
+ <string> "can_sleep" </string>
+ <string> "velocity/linear" </string>
+ <string> "velocity/angular" </string>
+ <string> "Sprite" </string>
+ <string> "texture" </string>
+ <string> "centered" </string>
+ <string> "offset" </string>
+ <string> "flip_h" </string>
+ <string> "flip_v" </string>
+ <string> "vframes" </string>
+ <string> "hframes" </string>
+ <string> "frame" </string>
+ <string> "modulate" </string>
+ <string> "region" </string>
+ <string> "region_rect" </string>
+ <string> "CollisionPolygon2D" </string>
+ <string> "build_mode" </string>
+ <string> "polygon" </string>
</string_array>
<string> "version" </string>
<int> 1 </int>
<string> "conn_count" </string>
<int> 0 </int>
<string> "node_count" </string>
- <int> 2 </int>
+ <int> 4 </int>
<string> "variants" </string>
<array len="17" shared="false">
- <node_path> "" </node_path>
<bool> True </bool>
<real> 1 </real>
<vector2> 0, 0 </vector2>
<real> 0 </real>
<vector2> 1, 1 </vector2>
- <int> 0 </int>
- <resource resource_type="Script" path="res://moving_platform.gd"> </resource>
+ <resource resource_type="Script" path="res://moving_platform.*"> </resource>
<dictionary shared="false">
<string> "__editor_plugin_states__" </string>
<dictionary shared="false">
@@ -71,22 +92,16 @@
<string> "pixel_snap" </string>
<bool> False </bool>
<string> "zoom" </string>
- <real> 1.850616 </real>
- <string> "use_snap" </string>
- <bool> True </bool>
+ <real> 1.360373 </real>
<string> "ofs" </string>
- <vector2> -406.735, -157.32 </vector2>
- <string> "snap" </string>
- <int> 32 </int>
+ <vector2> -210.652, -172.81 </vector2>
</dictionary>
<string> "3D" </string>
<dictionary shared="false">
- <string> "deflight_rot_y" </string>
- <real> 0.628319 </real>
<string> "zfar" </string>
<real> 500 </real>
<string> "fov" </string>
- <real> 179 </real>
+ <real> 400 </real>
<string> "viewports" </string>
<array len="4" shared="false">
<dictionary shared="false">
@@ -96,12 +111,10 @@
<real> 0 </real>
<string> "y_rot" </string>
<real> 0 </real>
- <string> "listener" </string>
- <bool> True </bool>
- <string> "use_environment" </string>
- <bool> False </bool>
<string> "use_orthogonal" </string>
<bool> False </bool>
+ <string> "use_environment" </string>
+ <bool> False </bool>
<string> "pos" </string>
<vector3> 0, 0, 0 </vector3>
</dictionary>
@@ -112,12 +125,10 @@
<real> 0 </real>
<string> "y_rot" </string>
<real> 0 </real>
- <string> "listener" </string>
+ <string> "use_orthogonal" </string>
<bool> False </bool>
<string> "use_environment" </string>
<bool> False </bool>
- <string> "use_orthogonal" </string>
- <bool> False </bool>
<string> "pos" </string>
<vector3> 0, 0, 0 </vector3>
</dictionary>
@@ -128,12 +139,10 @@
<real> 0 </real>
<string> "y_rot" </string>
<real> 0 </real>
- <string> "listener" </string>
+ <string> "use_orthogonal" </string>
<bool> False </bool>
<string> "use_environment" </string>
<bool> False </bool>
- <string> "use_orthogonal" </string>
- <bool> False </bool>
<string> "pos" </string>
<vector3> 0, 0, 0 </vector3>
</dictionary>
@@ -144,12 +153,10 @@
<real> 0 </real>
<string> "y_rot" </string>
<real> 0 </real>
- <string> "listener" </string>
+ <string> "use_orthogonal" </string>
<bool> False </bool>
<string> "use_environment" </string>
<bool> False </bool>
- <string> "use_orthogonal" </string>
- <bool> False </bool>
<string> "pos" </string>
<vector3> 0, 0, 0 </vector3>
</dictionary>
@@ -158,18 +165,12 @@
<int> 1 </int>
<string> "default_light" </string>
<bool> True </bool>
- <string> "ambient_light_color" </string>
- <color> 0.15, 0.15, 0.15, 1 </color>
<string> "show_grid" </string>
<bool> True </bool>
<string> "show_origin" </string>
<bool> True </bool>
<string> "znear" </string>
<real> 0.1 </real>
- <string> "default_srgb" </string>
- <bool> False </bool>
- <string> "deflight_rot_x" </string>
- <real> 0.942478 </real>
</dictionary>
</dictionary>
<string> "__editor_run_settings__" </string>
@@ -182,17 +183,19 @@
<string> "__editor_plugin_screen__" </string>
<string> "2D" </string>
</dictionary>
- <vector2> -96, -32 </vector2>
- <resource resource_type="TileSet" path="res://tileset.xml"> </resource>
- <vector2> 64, 64 </vector2>
- <int> 16 </int>
- <matrix32> 1, 0, 0, 1, 0, 0 </matrix32>
- <int> 2 </int>
<int> 1 </int>
- <int_array len="6"> 0, 536870927, 1, 536870926, 2, 15 </int_array>
+ <resource resource_type="Shape2D" path="local://1"> </resource>
+ <matrix32> 1, -0, 0, 1, 0, 0 </matrix32>
+ <bool> False </bool>
+ <int> 3 </int>
+ <int> 0 </int>
+ <resource resource_type="Texture" path="res://moving_platform.*"> </resource>
+ <color> 1, 1, 1, 1 </color>
+ <rect2> 0, 0, 0, 0 </rect2>
+ <vector2_array len="4"> -88, -24, 88, -24, 88, 24, -88, 24 </vector2_array>
</array>
<string> "nodes" </string>
- <int_array len="80"> -1, -1, 1, 0, -1, 13, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 1, 11, 7, 12, 8, 13, 3, 14, 2, 0, 0, 0, 16, 15, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 9, 7, 4, 8, 5, 9, 6, 10, 1, 17, 6, 18, 10, 19, 11, 20, 12, 21, 13, 22, 14, 23, 15, 24, 2, 25, 4, 26, 15, 27, 16, 0 </int_array>
+ <int_array len="150"> -1, -1, 1, 0, -1, 11, 2, 0, 3, 1, 4, 1, 5, 0, 6, 2, 7, 3, 8, 4, 9, 5, 10, 6, 11, 2, 12, 1, 0, 0, 0, 14, 13, -1, 23, 2, 0, 3, 1, 4, 1, 5, 0, 6, 2, 7, 3, 8, 4, 15, 7, 16, 8, 17, 9, 18, 10, 19, 11, 20, 1, 21, 1, 22, 3, 23, 10, 24, 10, 25, 12, 26, 10, 27, 0, 28, 0, 29, 2, 30, 3, 0, 1, 0, 31, 31, -1, 18, 2, 0, 3, 1, 4, 1, 5, 0, 6, 2, 7, 3, 8, 4, 32, 13, 33, 0, 34, 2, 35, 10, 36, 10, 37, 7, 38, 7, 39, 12, 40, 14, 41, 10, 42, 15, 0, 1, 0, 43, 43, -1, 9, 2, 0, 3, 1, 4, 1, 5, 0, 6, 2, 7, 3, 8, 4, 44, 12, 45, 16, 0 </int_array>
<string> "conns" </string>
<int_array len="0"> </int_array>
</dictionary>
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index 06c97027f0..52f4d27497 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -28,6 +28,7 @@
/*************************************************************************/
#include "tile_map.h"
#include "io/marshalls.h"
+#include "servers/physics_2d_server.h"
void TileMap::_notification(int p_what) {
@@ -339,7 +340,7 @@ Map<TileMap::PosKey,TileMap::Quadrant>::Element *TileMap::_create_quadrant(const
q.canvas_item = VisualServer::get_singleton()->canvas_item_create();
VisualServer::get_singleton()->canvas_item_set_parent( q.canvas_item, get_canvas_item() );
VisualServer::get_singleton()->canvas_item_set_transform( q.canvas_item, xform );
- q.body=Physics2DServer::get_singleton()->body_create(body_mode);
+ q.body=Physics2DServer::get_singleton()->body_create(use_kinematic?Physics2DServer::BODY_MODE_KINEMATIC:Physics2DServer::BODY_MODE_STATIC);
Physics2DServer::get_singleton()->body_attach_object_instance_ID(q.body,get_instance_ID());
Physics2DServer::get_singleton()->body_set_layer_mask(q.body,collision_layer);
Physics2DServer::get_singleton()->body_set_param(q.body,Physics2DServer::BODY_PARAM_FRICTION,friction);
@@ -590,15 +591,15 @@ void TileMap::set_collision_layer_mask(uint32_t p_layer) {
}
}
-Physics2DServer::BodyMode TileMap::get_collision_body_mode() const{
+bool TileMap::get_collision_use_kinematic() const{
- return body_mode;
+ return use_kinematic;
}
-void TileMap::set_collision_body_mode(Physics2DServer::BodyMode p_body_mode) {
+void TileMap::set_collision_use_kinematic(bool p_use_kinematic) {
_clear_quadrants();
- body_mode=p_body_mode;
+ use_kinematic=p_use_kinematic;
_recreate_quadrants();
}
@@ -816,12 +817,12 @@ void TileMap::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_center_y","enable"),&TileMap::set_center_y);
ObjectTypeDB::bind_method(_MD("get_center_y"),&TileMap::get_center_y);
+ ObjectTypeDB::bind_method(_MD("set_collision_use_kinematic","use_kinematic"),&TileMap::set_collision_use_kinematic);
+ ObjectTypeDB::bind_method(_MD("get_collision_use_kinematic"),&TileMap::get_collision_use_kinematic);
+
ObjectTypeDB::bind_method(_MD("set_collision_layer_mask","mask"),&TileMap::set_collision_layer_mask);
ObjectTypeDB::bind_method(_MD("get_collision_layer_mask"),&TileMap::get_collision_layer_mask);
- ObjectTypeDB::bind_method(_MD("set_collision_body_mode","body_mode"),&TileMap::set_collision_body_mode);
- ObjectTypeDB::bind_method(_MD("get_collision_body_mode"),&TileMap::get_collision_body_mode);
-
ObjectTypeDB::bind_method(_MD("set_collision_friction","value"),&TileMap::set_collision_friction);
ObjectTypeDB::bind_method(_MD("get_collision_friction"),&TileMap::get_collision_friction);
@@ -852,7 +853,7 @@ void TileMap::_bind_methods() {
ADD_PROPERTY( PropertyInfo(Variant::INT,"cell/quadrant_size",PROPERTY_HINT_RANGE,"1,128,1"),_SCS("set_quadrant_size"),_SCS("get_quadrant_size"));
ADD_PROPERTY( PropertyInfo(Variant::MATRIX32,"cell/custom_transform"),_SCS("set_custom_transform"),_SCS("get_custom_transform"));
ADD_PROPERTY( PropertyInfo(Variant::INT,"cell/half_offset",PROPERTY_HINT_ENUM,"Offset X,Offset Y,Disabled"),_SCS("set_half_offset"),_SCS("get_half_offset"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/body_mode",PROPERTY_HINT_ENUM,"Static,Kinematic"),_SCS("set_collision_body_mode"),_SCS("get_collision_body_mode"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"collision/use_kinematic",PROPERTY_HINT_NONE,""),_SCS("set_collision_use_kinematic"),_SCS("get_collision_use_kinematic"));
ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision/friction",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_collision_friction"),_SCS("get_collision_friction"));
ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision/bounce",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_collision_bounce"),_SCS("get_collision_bounce"));
ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_layer_mask"),_SCS("get_collision_layer_mask"));
@@ -886,7 +887,7 @@ TileMap::TileMap() {
bounce=0;
mode=MODE_SQUARE;
half_offset=HALF_OFFSET_DISABLED;
- body_mode=Physics2DServer::BODY_MODE_STATIC;
+ use_kinematic=false;
fp_adjust=0.01;
fp_adjust=0.01;
diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h
index 52e8eae306..c8708e1bed 100644
--- a/scene/2d/tile_map.h
+++ b/scene/2d/tile_map.h
@@ -33,7 +33,6 @@
#include "scene/resources/tile_set.h"
#include "self_list.h"
#include "vset.h"
-#include "servers/physics_2d_server.h"
class TileMap : public Node2D {
@@ -61,7 +60,7 @@ private:
Mode mode;
Matrix32 custom_transform;
HalfOffset half_offset;
- Physics2DServer::BodyMode body_mode;
+ bool use_kinematic;
union PosKey {
@@ -179,8 +178,8 @@ public:
void set_collision_layer_mask(uint32_t p_layer);
uint32_t get_collision_layer_mask() const;
- void set_collision_body_mode(Physics2DServer::BodyMode p_body_mode);
- Physics2DServer::BodyMode get_collision_body_mode() const;
+ void set_collision_use_kinematic(bool p_use_kinematic);
+ bool get_collision_use_kinematic() const;
void set_collision_friction(float p_friction);
float get_collision_friction() const;