我目前正在从事射击游戏。因为我的拍摄次数是固定的。但我喜欢根据某人按下键盘键的时间来使其可变。如果按键时间更长,应该会产生更多的能量。
这是我的代码。
{
// Create projectile
worldEntities.Add(new Sphere(GraphicsDevice, 0.1f, 0.2f, Character.EyePosition() + Character.LookTowards(), 0.8f, Color.Blue));
// Add gravity to projectile
(worldEntities[worldEntities.Count - 1] as RigidBody).Acceleration = new Vector3(0f, -10f, 0f);
// Calculate launch velocity
Vector3 launchVelocity = Character.LookTowards() * 10f;
// Set particle velocity to launch velocity
(worldEntities[worldEntities.Count - 1] as RigidBody).Velocity = launchVelocity;
// Reset timer
timer = 1f;
}