Local personSprite = display.newSprite( mySheet, spriteOrderData) Local mySheet = graphics.newImageSheet( "personSheet.png", sheetInfo:getSheet() ) But person1 – person4 refer to the 4 person images I have imported into TexturePacker. Your images could be called differently if you loaded different images in your texturepacker. The total of 4 frames are defined in a as should be called person1 – person4. Next we add a physics body and get the first frame called person1. We have to create our sprite which I called personSprite and pass the sheet and animationorder called spriteOrderData. The animation will start with frame 1 and ends at frame 4 and will loop in total 2 times within 1000 milliseconds for each run.
Second we define a spriteanimation order. Local background = display.newRect( 0, 0, ntentWidth, ntentHeight )įirst load your personSheet.png (line 1). This will make it easier to see the animation. Local physicsData = (require "shapedefs").physicsData(1.0) tDrawMode( "hybrid" ) - comment out in case you dont want to see the physics shapes In this line we refer to the a (which we have created with the PhysicsEditor). In case you have worked with physics before then you will notice that only the last line is different. If you followed thus far you should have beside your standard lua files the following files in your project:Īdd the following two lines for housekeeping, which we will use later to position stuff more easily. This lua files describes the exact shape of your images.
Click publish and save the file as a and make sure it is within your project files. Make any additional settings if you like. Click on the Shape tracer, a window will pop-up and click ok. Now open the PhysicsEditor and load all individual images.
The most important piece is the ameIndex which has the name, which you can use in your code to make the reference. In this lua file the data of each image is recorded.
The first one is your actual sheet (see image above). Make sure both of them are in your project files. TexturePacker should have created 2 output files which are important. Load your images in TexturePacker, select the data format Corona SDK (Imagesheet).
You can download the complete source code here. An Notice the Hybrid mode run as well with Corona’s Physics Engine.ġ) We create an imagesheet with our individual images using TexturePackerĢ) We can reference in our Corona Development to these individual images of the imagesheetģ) We use the PhysicsEditor to create precise shapes of our images, so when you use them in your game they don’t look like square boxes (important for Physics games)Ĥ) We create our sprite Animation based on the TexturePacker sheet and PhysicsEditor shape definitions. In case you are not familiar with TexturePacker click here and in case you are not familiar with the PhysicsEditor click here.
This post assumes that you know how to work with TexturePacker and the PhysicsEditor as I won’t explain how to create the output files of these two very useful programs. In this tutorial I show you how you can use TexturePacker to create a sheet and use the PhysicsEditor to use the same sheet to create an animated sprite.