From the course: Building Flash Games with Starling
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Adding the play button
From the course: Building Flash Games with Starling
Adding the play button
So the next thing we need to add to our menu state is our Play button, and this is obviously what you're going to click on when you want to actually start playing the game. So Starling actually has a class called Button which makes it very easy obviously to create buttons. So I'm going to come under our logo here, create a new variable called play, I'm going to set that equal to a new instance of the Starling.display.button class. Into this you can pass in different textures for the up and the down states, we're not going to deal with that, we're just going to do an up state to keep it simple. And for the texture, again, we're going to use a texture which is in that texture atlas. So Assets.ta.getTexture and the texture is called "playButton", and let's go ahead and create that playButton as an instance variable. Now when we're dealing with buttons there is a special event in Starling called a triggered event and that's essentially going to be fired whenever you click on the button…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.