Creating the Bullet class


show more Creating the Bullet class provides you with in-depth training on Developer. Taught by Lee Brimelow as part of the Building Flash Games with Starling show less
please wait ...

Creating the Bullet class

So now that we have our hero created, the next thing we are going to want to do with it is to be able to fire bullets. So the first thing we have to do is to create a Bullet class, and again, we are going to do it in our objects package, so I'm going to create a new ActionScript Class. It's going to be called Bullet. And again, the Superclass is going to be starling.display.Sprite. So this one is going to be pretty simple, all we need to do is to get that texture out of our Texture Atlas and feed it to an image object. So we are going to say var img, it's going to be of type image, it's equal to new Image, and let's reach out and grab that texture so it's in the Assets class to our ta, which is our Texture Atlas, call the getTexture method and pass in the string name for the texture which is bullet.

And let's set its pivotX and pivotY properties. So we want to do pivotX = img.width * 0.5, and set pivotY = img.height * 0.5, and then lastly we will add this image...

Creating the Bullet class
Video duration: 1m 44s 2h 57m Intermediate

Viewers:

Creating the Bullet class provides you with in-depth training on Developer. Taught by Lee Brimelow as part of the Building Flash Games with Starling

please wait ...