Alert Dialogs are an excellent way of providing a confirmation screen, or letting users select from a set of options. However, customising them can be tricky, and they have a maximum of 3 buttons (positive, neutral, negative), all of which are positioned differently in different Android versions. If advanced customisation or more than 3 buttons are required, the usual method of modifying colours etc (styles) isn’t enough!
In a previous post, it was discussed how to export levels from an Android game (in this case Connect Quest) so that other players could play them. Now that they’re exported, we need to be able to import them again! This post will explain how to import QR codes either directly from the camera, or embedded within an image on the file system.
Connect Quest is an android game where players rotate tiles to make a city flow. They also have the ability to create their own levels, and share them with other players. The data transfer method chosen was QR codes, since it was the most widely-used and compact method available.
Many games (such as my own Pixel Blacksmith and Blacksmith Slots) contain an XP / level system, where performing actions will reward experience, and eventually new levels. These new levels often unlock new content, or provide currency, so keeping players incentivised without feeling like a “grind” is a tricky balance.
Whilst building a turn based strategy shooter, weapons needed to have “ideal ranges”. For example, a melee weapon should only work from 1 tile away, a shotgun should prefer short ranges, a sniper rifle should prefer long ranges, etc. The non-melee weapons should still work outside of their ideal range, but with reduced damage.
During various events in Pixel Blacksmith, a sound effect needs to play. There is more than one possible sound effect per event, so one needs to be randomly picked each time.
In Pixel Blacksmith, visitors arrive in the shop and have demands that need fulfilling. The visitors are mostly random, but each visitor is weighted to appear more or less frequently, to allow for rarer visitors. These weighted probabilities also need to be modifiable, to add seasonal visitors etc.
Occasionally whilst developing a UI in Android, padding will have to be set programmatically, this usually happens when padding varies according to the number of items on screen. These values must be set in pixels, but the size of a pixel will vary massively, according to the density of the screen (for example, 2 1920px by 1080px and 192px by 108px screens may be the same physical size, but the former will have 10 times more pixels in any given centimetre). As such, display pixels (essentially a unit that aims to avoid this issue) must be used, however these values need converting into real pixels.
Pixel Blacksmith is an Android game where players craft and sell items to visitors, in order to make a profit to buy upgrades / more resources. These items can be enchanted with gems, and the item’s image needs to be tinted the gem’s colour to reflect this.
Many apps need to ship with a local database, and many apps also use a ORM to handle their database actions (I personally use and recommend Sugar). Tying together these two approaches requires some sort of compromise, often manually copying a SQLite database around the device’s filesystem.
Looking for non-software development posts? I've got another blog for those!