Posts Tagged ‘Programming’

Programming related posts.

Android: obtaining SD card memory information

Click here to read Android: obtaining SD card memory information

This Android tutorial explains how to obtain the primary external storage (normally, the SD card) information, such as the total available space and how much memory it has left to be consumed by applications and data. Fortunately, this is a short and simple code, that can be used to create file explorer app, or to check if the SD card has enough space to copy data into the external storage. An example Eclipse project with the source code is available for download at the end of the post. It requires Android 2.1 (Eclair) and works both on a real and emulated devices.

In simple terms, the code below checks for a connected SD card, by querying its state. If a external device was found, it then obtains the external memory’s total and available sizes, returning the values in GB, MB, KB and bytes: (more…)

Android: Disabling anti-aliasing for pixel art

Click here to read Android: Disabling anti-aliasing for pixel art

Android is great when it comes to displaying scaled pictures in applications and games since it tries to interpolate the pixels, making the resulting image look as good as possible. That works for almost every case, however, what about pixel art? This behavior isn’t good for that because, after scaling it, the resulting image will be “smoothed out”, invalidating the handcrafted pixel placement.

There are two options in this case: use an image with the correct size and never scale it, or try to disable anything that could be aliasing the image. This post is going to describe how to do the latter. As usual, an example project is available for download at the end of the post. (more…)

Android: Transparent or Translucent View Background

Click here to read Android: Transparent or Translucent View Background

This Android post is going to explain how to change the background color of a View, to make it completely or partially transparent. It may seen a little strange at first, but sometimes it makes sense to create a translucent or transparent background, like when coding an application with multiple viewports, such as a graphic editing tool, for example. Luckily, Android has already some built-in features that aids the programmer in achieving total or partial transparency at any required level.

So, to create a fully transparent background, all that’s needed is to add the following line to the Manifest file: (more…)

Android: Detecting Double Tap Events

Click here to read Android: Detecting Double Tap Events

This Android tutorial explains how to create an Activity that “listens” to double tap events. Doing that isn’t as trivial as getting a single tap from the screen, however writing a code that registers when the screen has been touched twice isn’t complex either. The example featured in this post works on the emulator and on a real Android device.

To implement the double tap, some classes and interfaces are going to be needed, but it’s best to show the example Activity code before explaining each one of them: (more…)

Unity: Raycast Reflection

Click here to read Unity: Raycast Reflection

As any person that has already used Unity’s Ray class knows, there’s no support for reflection, which could be useful for some specific cases. This post will try to offer a solution to that, explaining how to create a script which casts a ray that gets reflected when it hits a surface. Not only that, but the script also allows to set the number of times the cast ray should bounce. An example project with a scene and the code explained below is available for download at the end of the tutorial.

Before looking how the reflection script works, a scene must be set with some walls to reflect the ray. Additionally, a game object will be required to act as the source of the ray . To create the ray’s source, just select GameObject->Create Other->Cube: (more…)