But we just didn’t want to rush through the islands as the Thai islands are famous for their beauty and turquoise waters. By the way, did you know that Koh stands for Island in the Thai language? So in terms of scenery change? Not that much except for different islands with different views. I’m most excited about Koh Kradan and Koh Kong as these islands have barely any visitors or tourists. Besides Koh Lipe, we decided to visit Koh Lanta, Koh Kradan, Railay Beach and Koh Kong. We are still hopping around the Thai Islands, we decided to take some ferries around the different island in the Andaman sea, this is the sea on the left side of Thailand.
#Texturepacker tutorial code#
You can find the updated Rolly Bear World code in my GitHub Repository. That’s all folks, we have created an imagesheet with TexturePacker, defined our Physics shapes with PhysicsEditor and finally brought it all together in this tutorial. Physics.addBody( platform, physicsData:get(platformNum)) I also set the bodyType to “static” as I don’t want the platforms to be affected by gravity or the physics engine. We add the PhysicsEditor data to the platform object in a similar way as for creating the platform object (platformNum). Note that the drag and drop functionality is for a future post. I positioned them on the left so that the user can drag and drop them from one position onto the screen. In the next step we set x and y of the platform objects. When for example platformNum = 3 the for loop will display “platform-green128″. We set this x value in a new variable called platformNum which will be passed in the display.newSprite call. Everytime the for-loop is made x is incremented with 1 for as long as the size of the table is, in our case 5. Use the function display.newSprite instead of display.newImage (which we were used to up till now). In the next step we need to retrieve the image from the TexturePacker sheet. #platformNames checks for the total number of values in the platformNames table, this is an easy way to construct your for-loop as deleting or adding more values to your table won’t change your for-loop. Want we want to achieve is one block of code which displays all table values on the screen without having to code them separately. In the snippet you see platform-brown128, which is also our first item of our platformNames table. Line 8 displays the name which should be the same name as in your table. This table should look like the snippet below: When you open a you should see a large table (depending on the number of items in your TexturePacker file). In this table, which I called platformNames, we set the names exactly the same as they are listed in our a. For now, we only display some of these platforms on the screen.įirst, we create a table of the display objects (platforms) we want to load in our first level of Rolly Bear World. For Rolly Bear World we want platforms to be displayed on the screen, which the user eventually can drag and drop to certain areas in the game. But we still don’t see any objects on the screen? That’s right. We have successfully loaded our PhysicsEditor and TexturePacker output files in our game project. Jippie! See the green bounding boxes in the screenshot above. This way we somehow control that the PhysicsEditor output is actually working. Local physicsData = (require "platformshapes").physicsData(1.0)įor this tutorial it is very convenient when you set the Physics drawmodel to “Hybrid”, so Corona SDK shows you the bounding boxes of the objects in the game. Next, we need to load the PhysicsEditor lua file in our project by calling: Local myPlatformSheet = graphics.newImageSheet( "platformsheet.png", sheetInfo:getSheet() ) Local sheetInfo = require("platformSheet") Note that these instructions are also mentioned in your output file of TexturePacker as comments in the code. Next we great a new variable called myPlatformSheet and retrieve the platformsheet.png through sheetInfo:getSheet(). lua file (a) by simply calling the Corona SDK require call. Open the a file of the Rolly Bear Project. platformsheet.png (an png file with the images of TexturePacker). a (a lua file with the definition of your image sheet) (TexturePacker). a (PhysicsEditor, indicating the shapes of each display object). You should have the following TexturePacker and PhysicsEditor output files in your project: In case you missed the previous two tutorials you can visit them via the links below. In this post we continue with our previous two tutorials by loading the TexturePacker and PhysicsEditor data into our Corona SDK project.