Skip to main content

Posts

Showing posts with the label Corona SDK

Falling leaves with Corona SDK and transition2

The latest addition to my transition2 library for Corona is the convenience function fallingLeaf() . I was working on my iOS game  Ice Trap , trying to create a "confetti cannon" effect when the player completes a level and achieves three stars. While playing around with the existing transition functions I managed to reach a quite decent result by combining several different transitions. It took me a while to get there, so I realized that it would probably be nice to turn that combination of transitions into its own convencience function. At its simplest use, you only need a few lines of code to create a leaf that falls smoothly towards the bottom of the screen following a seemingly random pattern: local transition2 = require ( "transition2" ) local leaf = display.newImageRect( "leaf-64px.png" , 64 , 64 ) leaf.x, leaf.y = display.contentCenterX, 0 transition2.fallingLeaf(leaf, {}) Simplest possible use of fallingLeaf() Ok, so that l...

transition2.zRotate(): Rotate Corona display objects in the z dimension

I just added another transition function called zRotate() to my transition2 library for Corona. You guessed it, it rotates a display object in the z dimension around either the x or y axis. It requires the display object to have a path with four nodes (x1, y1) to (x4, y4), like images and rects do. If you want to know more about what transition2 is, you can read this blog post . A simple vertical rotation could look like this: transition.zRotate(coronaLogo, { degrees = 360 , time = 3000 , iterations = 0 , transition = easing.inOutSine, reverse = true , }) A little more complex example of a horizontal rotation with a color effect at the end of each iteration. Note that this example utilizes two new params: iterationDelay and onIterationComplete (which is not the same as onRepeat). transition.zRotate(coronaLogo, { degrees = - 1440 , time = 4000 , iterations = 0 , transition = easing.inOutQuad, perspective = 0.75 , ...

transition2: Extending Corona's transition library with custom transitions

Corona Labs has a great transition library that makes it very easy to perform some useful and common transitions on display objects, such as moving, scaling and rotating them. There are also plenty of different easing algorithms to choose from that affect the behavior of the transition effects. I've used this library a lot and I really like its ease of use. But there are certain things that you can't do with the transition library. One of them is to modify the fill and stroke colors of a display object to be able to fade smoothly from one color into another. UPDATE June 30, 2017: transition2 is now a full standalone rewrite of Corona's transition library. Not just an extension that wraps the transition library like the remaining text in this post suggests. I needed a color transition effect for  Ice Trap  to make some glowing image borders but had a hard time finding any solution that I felt comfortable in using, so I started rolling my own. To make a long story s...

Creating iOS App Store screenshots from Corona Simulator on Windows

Not very long ago you had to upload your App Store screenshots in many different resolutions for all the different iOS devices. A real pain. Fortunately, Apple realized this and simplified the screenshot upload process a lot. Now you only need to upload screenshots for the 5.5" iPhone and 12.9" iPad displays, and automatic scaling will be done for remaining devices with lower resolutions. It's recommended to grab your screenshots from a physical device, but what do you do if you don't have a 5.5" iPhone? Well, instead of buying a new device or scaling lower resolution graphics you can use the Corona Simulator to get the high resolution screenshots you're looking for. This is how I do it for my Corona SDK apps on my Windows machine, and my example assumes that your screenshots are taken in portrait mode and that your app is primarily designed for iPhone rather than iPad. You must of course also have a monitor that can handle the resolution of the screensho...

GPGS Corona SDK plugin + Google Drive API

I've been working on implementing Google Play Games Services (GPGS) for Ice Trap the last couple of days, using the new GPGS plugin for Corona SDK. Read all the docs top to bottom, configured everything accordingly, double-checked everything several times, but still got nothing more than an "Internal error" when trying to login from the Android app using one of my test accounts. Finally, I found this thread on the Corona forums . I followed the advice from the thread and enabled Google Drive API from the developers console at https://console.developers.google.com . Ta-dah! That's all that was missing, and now logging in to GPGS works as it should. Happy to have found the solution, but I can't believe that this wasn't mentioned anywhere in the docs or in the Google Play Developer Console. Or did I just miss it? I don't know, but it would have been really nice to somehow get a more descriptive error code/message than just "Internal error"...

Create iOS .ipa file from Corona SDK build

When building your iOS app with Corona SDK, the result is a . app  directory. How do you turn this into an .ipa file that can be uploaded to third party services like HockeyApp or TestFairy? The only working solution I've found this far is this: Build your .app file like you normally do Create a folder called Payload and place the .app file inside the Payload folder. Zip the Payload folder and rename the zip file to any-filename-here.ipa . That's it. Not very hard, but annoying to have to do this for each new build you need to upload. I have no idea why this isn't built into the Corona Simulator. Here's a little bash script that handles the procedure. Just change the values of the variables, save the code to a .sh file in your build folder and run it from there. #!/bin/bash APP_DIR = "your-app-dir.app" ZIP_FILE = "zip-filename.zip" IPA_FILE = "ipa-filename.ipa" rm "$IPA_FILE" rm -rf Payload mkdir Payload cp ...

Rewarding players for playing every day in Corona SDK

Rewarding players for coming back and playing your game every day is nothing new, and is probably used in most successful games out there in one way or another. I don't want to miss an opportunity to keep my Ice Trap players for a little longer if possible, so I've implemented a simple daily rewards solution in Corona SDK to handle this. My solution is the simplest possible really: Give the player a reward if he/she plays two days in a row. The reward will be the same every day regardless of the number of consecutive days played. I guess you could make this just as advanced as you like, with increasing rewards after a specific number of days, different rewards on different days and so on. But for the moment I don't see a need for that, and a flat reward will do just fine to start with. Recently I implemented a concept in Ice Trap called level keys, allowing the player to unlock the next level if getting stuck. The player starts the game with a few keys, and can then ea...

Generate app icons using bash script in Windows

Generating an app's icon in all necessary sizes for both Android and iOS can be really time consuming and boring. It would be ok to do this work manually if you'd only have to do it once for each app just before release. Unfortunately that's not the case since the final app icon is most likely something that evolves through iteration. Needless to say, there is time to save by finding an efficient way to automate the icon generation. There are many tools out there that can help out with this. I've tried a couple of them and they've all worked just fine. The problem is that I've found that they don't actually save me that much time in the end. For iOS, you need a completely square icon and iTunes/iOS will handle the rounding of the corners for you. For Android on the other hand, you have complete freedom when designing the shape of your icon. I prefer to have my Android icon look as similar to the iOS icon as possible, which means that I'll have to cre...

Organizing display objects in layers in Corona SDK

Working with display objects and display groups in Corona SDK is fairly straightforward. Every Corona developer probably knows the basics of this and how you can organize your display objects in a hierarchy of display groups. All this is also pretty well documented by Corona Labs right here , so I'm not gonna go into details about any of this. Instead I'll show you how I've created a simple helper class called DisplayManager which I find very useful when it comes to leverage the concept of layers and to keep track of all display objects to avoid creating memory leaks by not cleaning up the display objects properly. What I want the DisplayManager class to help me with is basically a few things, that otherwise requires quite a lot of attention when coding: Leverage the concept of visual layers, and encapsulate functionality concerning layers in an object-oriented way, making it easy to extend when needed. Make sure that all display objects are cleaned up as they shou...

Testing GameAnalytics v2 for Corona SDK

I've been trying out the new GameAnalytics v2 plugin for Corona SDK recently. It has some nice new features, especially the progression events which simplifies tracking your players' progression through the game. After the initial setup of the plugin, which is really simple (unless you make stupid typos...), you can fire progression events like in this example: gameanalytics.addProgressionEvent { progressionStatus = "Complete" , progression01 = "world01" , progression02 = "level01" , progression03 = "phase01" , score = 100 } For Android I got my events flowing pretty quickly, but when testing on an iOS device, no progression events at all showed up in my GA dashboard. Searching through the log file from my device I found the following error message: Nov 8 14:27:36 iPhone Ice Trap[1869] <Notice>: Info/GA/Analytics: Validation fail - progression event - progression02: Cannot be empty or above 6...

Avoiding pixel overlap between sprite frames

When working with sprites in Corona SDK I've quite often run into a problem with sprite sheet frames occasionally overlapping each other. When I say occasionally I mean that it doesn't happen for every new sprite I create even though the same sprite sheet is used, and it doesn't happen on all device resolutions. This is what it might look like when the overlap happens. Not pretty... The sprite's image sheet Sprites in action, pixel overlapping between frames To work around this problem in the past, I've just padded my sprite images with a couple of transparent pixels so that the possible overlap won't be visible even though it might still be there. This has caused some additional work both to set up the sprite sheet images, as well as calculating the frames' positions within the sheet. So I figured I was gonna look for another solution to be able to create sprite sheets without padding that still look good. Tough luck it turned out. The pixel o...

GameAnalyics plugin V2 for Corona SDK

I just received an e-mail saying that GameAnalytics has released an updated plugin for the Corona SDK. This is great news! In my last game Dragonflies I used the GameAnalytics plugin and was planning to do so in Ice Trap as well. It's an incredibly easy and efficient way to track your users' behavior, and if you're not doing it already I strongly recommend you to have a look at GameAnalytics. I haven't had time to test the new plugin yet, but will definitely do so in the near future. You can  read the full news about the plugin here .

Ice Trap level editor

One of the mistakes I made during the creation of my first mobile game Dragonflies was to not spend some time building a level editor. I figured the time it would take to finish the editor would be better spent just implementing the levels the fastest possible way. In my case this meant playing around with pieces of colored paper on a hand-drawn coordinate system, and then manually do the conversion from paper to json files. It actually worked out quite well in the beginning, until I started making more complex levels... Not only did it take a lot more time than expected, but designing levels became so incredibly monotonous and tedious. That's not exactly what you want when you're trying to be creative and come up with cool, new level ideas. Lesson learned. For my upcoming game Ice Trap I started out the same way, by just hand-crafting the level files in json format. But this time I knew it was only going to be temporary. When I got to the point where the gameplay felt soli...

Collision filters and bit masks in Corona SDK

Ok, so you're working on a game and you have some objects that you need to configure how they should (or shouldn't) collide with each other. If it's the first time you're doing this you'll probably end up at the Corona Labs page about collision detection pretty soon. You read through the section "Collision Filtering" and can't help but wonder: Does it really have to be this complicated? No, it doesn't. There is absolutely no reason to force knowledge about implementation details like category bits and bit masks onto the developer. All you want to do is specify if objects of type A should collide with objects of type B or not. But to do this, you need to assign unique bit identifiers to each object type, calculate the bit masks yourself, make sure that two colliding object types cross reference each other and so on. It gets really nasty as the number of object types grow. Consider the example from the Corona Labs documentation in which there ...