Posts tagged Android
Edit: I just added UTF-8 support
Localization is a key aspect in games, specially if you want to reach a wider audience. I recently ported Freegemas to the libgdx platform and, as the original one, I wanted to ship it with multi-language support. There is no such a thing as gettext for Java and I didn’t see the Android internationalization system as a good fit in a multiplatform development. That’s why I developed my little own internationalization module.
Its usage is extremely simple, first we need a media/languages.xml file where all the strings in our project will be located. The syntax is pretty straight forward, we lay language sections identified with the code for each language. Inside every language, we provide a list of key value pairs with the localized strings.
< ?xml version="1.0" encoding="UTF-8"?> <languages> <!-- English --> <language name="en_UK" > <!-- Menu --> <string key="Timetrial mode" value="Timetrial mode" /> <string key="How to play" value="How to play" /> <string key="Exit" value="Exit" /> </language> <!-- Spanish --> <language name="es_ES" > <!-- Menu --> <string key="Timetrial mode" value="Contrarreloj" /> <string key="How to play" value="Ayuda" /> <string key="Exit" value="Salir" /> </language> </languages>
We can retrieve localized strings in our project through the LanguagesManager class and its getString() method. It’s been implemented using the Singleton design pattern as we only need one instance accessible from, potentially, everywhere in the code. When we ask our manager for a certain string we will use its key, if it finds it within the current language, it’ll return it, otherwise it’ll return the key itself. That’s why using strings in a base language (English) as keys can be a good idea, those will be returned by default.
For now, it uses lazy initialization which means it’ll load the language the first time the getInstance() method is called but that might change in the future. It automatically detects the system language (no matter if we are on Android or a desktop environment) and it fallsback to English if the system language is not among the available ones in the media/languages.xml file. However, you can explicitly specify the language you want to load through the loadLanguage() method.
LanguagesManager lang; lang = LanguagesManager.getInstance(); String option1 = lang.getString("Timetrial mode"); String option2 = lang.getString("How to play"); String option3 = lang.getString("Exit");
Freegemas libgdx is open source (GPL v3) as is this internationalization module which means you’re more than welcome to download it, use it and improve it. If you do the latest, make sure you distribute it the same way as me.
I can’t believe it’s been almost three months since I started at Crytek UK, time has passed amazingly fast! Nevertheless, I’ve managed to get some stuff done game development wise. I’ve always wanted to jump into mobile and that’s what I’ve been doing during the last couple of weeks. May I present you Freegemas libgdx edition!
It’s basically a libgdx port of the original Freegemas, a simple Bejeweled like C++ Gosu puzzle game developed by José Tomás Tocino who I have to thank for the neat original code and the excellent art. This means you can run it on your desktop, Android phone and very soon on your browser through HTML5 sweetness.
Libgdx it’s an open source Java library that allows you to create multiplatform games (desktop, Android, HTML5) sharing the same code base. That alone is amazing enough, so kudos to Mario for the titanic work. The library uses OpenGL so the performance it’s quite good even though we’re talking about Java! It has so many features and associated tools that it’d take me a few days to cover them all. Plus the community is always very helpful, besides the forums there’s always someone on the IRC channel willing to save your ass. However, to be honest it’s a bit of a downside to me it’s lack of UFT-8 font rendering support. Maybe some other day I’ll talk with some more insight about libgdx.
This was a warm up project, bigger things are yet to come!
PS: I must not forget about the HTML5 version of the game, it’ll be available soon.
Lots of stuff has happened since I last posted something here. Crazy Eramus life, you want to do everything: projects, social life, studying… So, logically, the blog has been a little bit left behind. I just wanted to post a quick update about the two university projects I’ve been working on recently:
- Laterdroid: Read it Later client for Android created using the official SDK.
- Urban Race: time attack racing game developed using C# and the XNA framework.
For further information please go to each project’s page, you’ll find a more detailed description, screenshots, videos and download links. I was thinking of making both projects open source and upload them to a Google Code repository but I guess that’ll have to wait until they’re graded by the professors.
And now for something completely different…
Huge events have taken place recently, the dream has come true. Unfortunately, I can’t make anything public yet, I’ve only told my family and friends. However, I’ll soon post something on that matter.
Google anunció Music, su servicio de música gratuito a través de streamming en su evento I/O 2010 pero no fue hasta hace poco cuando se comenzaron a permitir registros para la fase beta. El problema es que sólo usuarios de Estados Unidos pueden solicitar la invitación y utilizar el cliente para Android. Afortunadamente hay un pequeño y sencillo procedimiento para poder saltarse esta barrera, sigue leyendo para saber cuál es. Gracias a mi buen amigo Javier por los enlaces y las pistas.
Ayer se celebró la !BarraLibreCamp en la UCA, una jornada de ponencias y talleres informales en la que todos los participantes deben aportar algo. Al final es un día lleno de actividades heterogéneas para pasarlo bien con amigos de todas partes y hablar (o flamear) sobre intereses comunes. A continuación, un pequeño resumen del evento y mi aportación.