Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
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 to this play list.
So now the Bullet class itself is not going to have an update method, and the reason is, we are going to create a bullet manager class, and this bullet manager is going to handle and keep track of all of our bullets, and it's going to handle animating the bullets, destroying the bullets and things like that. So for the actual Bullet class itself, it's simply just a visual representation of the bullet.
Get unlimited access to all courses for just $25/month.Become a member
61 Video lessons · 99373 Viewers
56 Video lessons · 112631 Viewers
71 Video lessons · 81455 Viewers
131 Video lessons · 39104 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.