This is part 2 of a multi-part tutorial series. For the first part, visit: Creating a Mole Whacking Game with CoronaSDK – Part 1. In this tutorial, we will learn how to move our Mole in the game and also a little about Object Oriented Programming (OOP). If this sounds scary, don’t be scared. This is just a fancy way of breaking different parts of a program into smaller parts so they can be re-used. Let’s begin…
Download the starter project from the APPlied Club projects page. Unzip the project.
Open the Corona Simulator and open the project in the Part 2 folder. Then open the main.lua file in Notepad++ or TextWrangler
We are going to move our Mole character to it’s own file so we can separate all of the code related to the mole. This will help us in the future to find any changes we need to make to the mole.
Create a new file called “MoleGenerator.lua” in the same folder as the main.lua file for MoleWhack. This is going to be a text file but instead of having the .txt extension, it should have the .lua extension.
Now open up main.lua and remove the lines that created the “myMole” object. Remove this:
This is part 1 of a multi-part tutorial series. For the second part, visit: Creating a Mole Whacking Game with CoronaSDK – Part 2. In this tutorial, we will learn how to begin our Mole Whacking game by placing the images on the screen.
Download the starter project from the APPlied Club projects page. Unzip the project.
Let's start by exploring the contents of our new project. Open the project folder and then open the images folder. Just take a look at some of the images in there to get an idea for what we have.
Open the Corona Simulator and open the project. Then open the main.lua file in Notepad++
Let's add one of the images to our simulator screen. Let's start with our "friend" the Mole. Add the following code in main.lua:
Before I explain what this code means, save and relaunch the project. You should see a brown speck in the top left of the simulator screen. This is our mole.
He's not really in a good place, so let's move him to the center of the screen for now so we can get a good look at him.
After the line we just added, let's add the two following lines to center our mole.
Lua
1
2
myMole.x=display.contentCenterX
myMole.y=display.contentCenterY
Save and relaunch the project and you should get a much better look at our Mole. Awww, isn't he cute?
Ok, let's go back and look at what that code actually means:
We created this infographic to help explain why we chose to focus on app development with students. If you are interested in learning more about APPlied Club and the methods behind APPlied Club, this could be helpful. If you are getting started with your own APPlied Club team, having this information is important to our mission and goals.
On Saturday at the December Meetup, our app development team from Patapsco High School gave a great presentation on one of their favorite aspects of app development and promotion as a part of the morning session.
The Digital Rebels team from Patapsco wanted to present a topic to the other Meetup attendees that others could benefit from. The students on this team have become quite proficient with creating video trailers to market and promote their apps. They wanted to share this expertise with teams who are just getting started and have not yet had the opportunity to promote an app they have created.
Stay tuned for a couple more posts about the December Meetup!
The APPlied club has opened so many new doors for the students involved. It’s been fabulous to watch the students go from users of mobile technology to creators of mobile technology tools. Ryan Imbriale, Principal, PHS&CFA
We live in a different society now and in order to reach today’s generation, we need to step into their shoes. The APPlied Club does just that. We meet students on their level so the enthusiasm and interest has already been born. Terri Grimes, Tech Liaison, PHS&CFA
APPlied Club has helped me to appreciate technology so much more than I already did. I never knew how much work goes into the simple devices that we use everyday. And plus, how many people can say that they helped make an app? Courtney Parto, Student, APPlied Club Member PHS&CFA