Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
So in the last two movies we created our Bullet class and our BulletManager class which helps to keep track of all those bullets. Well we are going to do a very similar thing for our alien. We are first going to create an Alien class and then an AlienManager class. So I'm going to go to my Objects package, right-click, and say New > ActionScript Class and I'm going to call it Alien. Now for a Superclass, we don't want Sprite, we want MovieClip now, because again this actually contains an animation within itself and make sure you choose Starling.display.MovieClip.
Now you'll see that it expects two arguments to the constructor. First is a Vector of Texture objects, which we are going to get out of our Texture Atlas, and then a frames per second so this can actually have an independent frame rate different from the frame rate of our main game. So I'm going to remove these arguments from the constructor and we are going to send them into the super constructor. So first we need to get those textures out of our Texture Atlas. So I'm going to say Assets, and make sure we import that, .ta.getTextures.
We've been using getTexture when you need to get a single one. If you need to get multiple, you use getTextures and then we pass in our root name which is alien, and if you forgot what that name is, you can always look at the Texture Atlas XML file. Then we are going to pass in 12 for the frame rate. Now much like our other objects, we want to set the pivot point of this movie clip directly in the center. So I'm going to set pivotX = width * 0.5 and then we are going to do the same thing for pivotY and this will be height * 0.5 like that.
So that's all we need to do for the alien. Again, similar to the bullet. The difference is that it's not just a static sprite that we are creating here, this is an animated object and that's why we use MovieClip instead of Sprite.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 98538 Viewers
61 Video lessons · 85831 Viewers
71 Video lessons · 69730 Viewers
56 Video lessons · 102035 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.
Your file was successfully uploaded.