简单添加ScriptComponent序列化功能
This commit is contained in:
@ -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))
|
||||
|
||||
@ -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;
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user