Creating the Score class


show more Creating the Score 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 Score class

So the last thing we are going to add to our game is just a simple high score text field. And what I'm going to do is create a new object class. I am going to go to my objects package, say New > ActionScript Class, and I am going to call it Score. Now I am just going to subclass Sprite. Now if you only literally wanted a text field, you could in subclass text field. But I am just using this because, generally speaking, you might want to add more to it in the future, and if so, you need to display object container. So I am going to subclass starling. display.Sprite, and in the constructor here I am going to create a new variable called score, and that's going to be equal to a new text field object, a new starling.text.TextField.

And to the constructor of this I am going to give it a width of 300, height of 100. I am going to give it an initial text value of 0, because we don't have any score when we come in. I am going to use the KomikaAxis font. That's our bitmap font tha...

Creating the Score class
Video duration: 4m 18s 2h 57m Intermediate

Viewers:

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

please wait ...