Clear
Introduction
Why should Clear (usually) not be used on PositionedObjectLists made in Glue?
if(InputManager.Keyboard.KeyPushed(Keys.Space))
{
Entities.Bullet bullet = new Entities.Bullet();
BulletList.AddBullet(bullet);
}// The if-statement checks to see if the user pressed the space bar:
if(InputManager.Keyboard.KeyPushed(Keys.Space))
{
// The following line of code creates a bullet. Note that
// when a new Bullet is created, it is instantiated and also added
// to the engine. That means that if the bullet has a Sprite, it will
// be drawn, and if the bullet has velocity, it will move. You do not have
// to add the bullet to the BulletList for the Engine to have a reference to
// this new Bullet.
Entities.Bullet bullet = new Entities.Bullet();
// The following line of code adds the bullet to the BulletList stored in your
// Screen. There are two reasons why this is typically done:
// 1. So that you can use the BulletList in your screen to check for collision
// or any other custom logic.
// 2. So that Glue can generate code to automatically clean up all Bullets when
// the Screen is destroyed.
BulletList.AddBullet(bullet);
}Last updated
Was this helpful?