We already have the platforms in Rolly Bear World and we can move them around. In this post we extend our code base so that the user can rotate them. In case you missed the post about making display objects in Corona SDK drag and moveable on the screen, click here.
Watch the movie of the implementation.
I have been working on Rolly Bear World now for almost two months and some of my lua files are getting very crowded with code blocks and repetition of similar code patterns. In this post, we will not add any additional functionality to Rolly Bear World; but we will be restructuring some of the code and creating some Object-Oriented patterns.
Start with creating a new lua file in your project and call it fixedScene.lua. In this lua file we will add all the static scene objects of the levels: the invisible walls, the 2 bushes, the background bush, the floor, the two wooden signs, the chest, and the rock. In fixedScene.lua create a function called createStaticBackgroundElements and copy/ paste all the static elements in this function. Next create a global group variable called: myStaticgroup = display.newGroup. We need to insert each background element in this group. So we can handle the removal of these objects between scenes later via our Storyboard implementation.
In the last post we created the display objects (platforms) for Rolly Bear World using a for-loop. In the final game the user should be able to drag or move these platforms to a strategic position to get Rolly Bear to the treasure chest. In the code below we create this functionality for the user to drag the platforms around the screen.
In this post we continue with our previous two tutorials by loading the TexturePacker and PhysicsEditor data into our Corona SDK project. In case you missed the previous two tutorials you can visit them via the links below.
- PhysicsEditor and Corona SDK
- TexturePacker and Corona SDK
You should have the following TexturePacker and PhysicsEditor output files in your project:
- platformshapes.lua (PhysicsEditor, indicating the shapes of each display object).
- platformSheet.lua (a lua file with the definition of your image sheet) (TexturePacker).
- platformsheet.png (an png file with the images of TexturePacker).
In my previous post I introduced TexturePacker to handle a lot of images in a simple way to improve i.e. game performance, the developer of TexturePacker created another program called PhysicsEditor. With PhysicsEditor you can easily trace your display objects so when the object bounce with other objects in your game it looks like the object has the real shape and not some bounding box around it. Often images have a transparent background which determines the real “image”, but when two display objects collide we want to images to collide as there shapes and not a collision of the larger transparent backgrounds. Well, this can be solved with the tracing tool of PhysicsEditor. Besides the tracing, another great thing about PhysicsEditor is that you can set your properties of each individual display object.
In case you’re new to PhysicsEditor, you can download the program here: http://www.codeandweb.com/physicseditor
I used TexturePacker to organize some of my art work for Rolly Bear World. In the Rolly Bear World game the player needs to move around different platforms to guide Rolly Bear to the treasure chest. All the objects which can be dragged and moved by the player I included in one single image sheet using TexturePacker. Why? TexturePacker is a great tool to keep your project organized so you don’t get to many image files in your project; as TexturePacker creates one image sheet with a large part of my art work it saves memory and thus increase the performance of the game. Lets not forget it is super easy to create the required @2x files for re-scaling across devices. If you missed the discussion around re-scaling for different devices read this post.
In case you you dont use TexturePacker yet for your Corona SDK developments, check it out here: http://www.codeandweb.com/texturepacker/.
I the last few days we were traveling a lot so I did not had much time to make any large changes to my Rolly Bear World Project. Internet and Wifi was shitty which made it even harder to look up any Corona SDK resources. Nevertheless, I made a few changes which were a bit easier to do without having access to the Internet.
I added a bit more art work to the project so Rolly Bear World will look a bit more appealing to the larger public. I mentioned before that I was planning to add these kind of changes later, but I guess due to the traveling and not having access priorities changed just to keep on having progress with the game and try to have it finished by the end of my trip. What did I change? A few background images like bushes to both the level screens as well as the menu screen. I added some clouds which move through the sky. I also added a few lines of code that when a user clicks on the back-button or on the level icons the user gets the feeling of a button press. I did this by using the Corona SDK xScale and yScale APIs.
As always you can find the code in my GitHub Repository
Finally, I reached the first big milestone of my Rolly Bear World project. In the last couple of days I added the first gameplay interaction to the game. In this post we will start integrating the physics engine provided by Corona SDK, add the functionality to launch Rolly Bear into the physics world, and add some basic new art work to the game.
But first, below you can find some pictures of Indonesia. We rented a motorbike and explore the island Lombok. We zip through jungle roads, past palm trees and little villages. After a hour we suddenly found a very secluded beach called Tanjun Aan. Personally, this was the most beautiful beach I ever saw in my life. Besides a guy selling 2 Dollar coconut drinks we were the only two people on the beach. The water was turquoise and warm, it felt like heaven :).
One of Corona’s strengths is the ability to deploy across different Operating Systems. In this post we make some changes to our code base to support multiple devices (iOS and Android). As this requires some changes in our config.lua and some understanding how it works I thought it would be worthwhile to write a post about this topic. Honestly, it took me a day to figure out everything despite the many articles already written about this topic.
Still in Indonesia, we travelled to Bali, which is one of the islands of Indonesia. The trip from Lombok to Bali took us almost six hours because the boat ride was longer than expected and we had some delays along the way. The problem with Bali is that it is hard to move around. There is barely any public transportation and you either take a cab or rent a motorbike. We visited some very nice rice fields and temples. Most of Indonesia is Muslim, but Bali is Hindu. Countries with a Hindu religion are often directly recognizable because of the many temples and shrines. So Bali is rich on random temples and some very large temples. One of the temples we visited was the Mother Temple of Besakih (Stunning!). Bali is one of these places, its good that we have visited it, but we won’t come back here. Bali is a tourist island full of western stores, prices and resorts. This is just not the way we like to travel. We probably will only stay for a few days and move out.
In this post we will continue with the storyboard work we did in the previous post but we will be creating a more appealing look & feel by adding some art work and additional animations. Also we will add a level grid to the play game section.
Currently I’m in Indonesia, after clearing customs and security we both got very sick. We think we ate some bad chicken in Kuala Lumpur. Anyhow, we had severe food poisoning for a couple of days, resulting that we stayed for 4 days in southern Lombok. Getting food poisoning was part of our expectations, but being a first-timer I never thought it makes you feel that bad. We took 2 days ago a local boat to the Gili islands (northern Lombok). The boat was a really cool experience, we were sitting on a food supply boat for the islands, and beside another Dutch couple we were the only foreigners on the boat. Maneuvering with large backpacks between food and boxes with eggs was quite a challenge.