简单添加ScriptComponent序列化功能

This commit is contained in:
2025-07-18 14:19:10 +08:00
parent e0bfdd9c4e
commit 1bdb1d240e
10 changed files with 326 additions and 58 deletions

View File

@ -8,7 +8,7 @@ namespace Sandbox {
// private TransformComponent m_Transform;
// private RigidBody2DComponent m_Rigidbody;
public float MoveSpeed;
/*
void OnCreate()
{
@ -23,7 +23,7 @@ namespace Sandbox {
{
// Console.WriteLine($"Player.OnUpdate: {ts}");
float speed = 1.0f;
float speed = MoveSpeed;
Vector3 velocity = Vector3.Zero;
if(Input.IsKeyDown(KeyCode.UP))

View File

@ -8,7 +8,8 @@ namespace Sandbox {
private TransformComponent m_Transform;
private RigidBody2DComponent m_Rigidbody;
public float Speed = 1.0f;
public float Force;
public float Time;
void OnCreate()
{
@ -20,9 +21,9 @@ namespace Sandbox {
void OnUpdate(float ts)
{
// Console.WriteLine($"Player.OnUpdate: {ts}");
Time += ts;
float speed = Speed;
float speed = Force;
Vector3 velocity = Vector3.Zero;
if(Input.IsKeyDown(KeyCode.W))
@ -36,14 +37,6 @@ namespace Sandbox {
velocity.X = 1.0f;
m_Rigidbody.ApplyLinearImpulseToCenter(velocity.XY * speed, true);
/*
velocity *= speed;
Vector3 translation = m_Transform.Translation;
translation += velocity * ts;
m_Transform.Translation = translation;
*/
}
}