Peach Maps – Searchable Apple Maps on your browser before official API is released

Two days ago I found out that Apple website featured an Apple Maps map to show this year’s WWDC location so I checked out its API and built a quick demo which allows you to search addresses and display them on Apple Maps: Peach Maps 🗺 (source code).

I added a search form which uses OpenStreetMap to get the results. The project only uses static files so it can be easily hosted on any server.

Introducing… MawKit

Recently I’ve released two iOS games (with Javier Rodríguez Vidal‘s and Víctor Grau Moreso‘s help). Both games use Cocos2d-x engine and a custom open source framework built on top of it named MawKit which I want to introduce in this post.

Why another framework?

We started developing Hop Raider last year’s November. At that moment there was a beta project called SDKBox focused on providing cross-platform plugins to Cocos2d-x but our experience was pretty frustrating: ads plugins which used outdated third-party APIs and spammy log-level, leaderboards/achievements plugins really buggy, almost no support for OS X, not-well documented plugins and features missing.

So we decided to develop our own solution, originally focused on offering a cross-platform (Android, iOS, OS X) implementation for ads and leaderboards/achievements, and called it MawKit. We developed the first version as we wrote Hop Raider and refactored it to make it open-source when we developed Blimp Journey.

It is written in C++, Java and Objective-C++ and offers callbacks to handle asynchronous operations, avoiding busy-waiting and global variables. MawKit is fully documented with Doxygen although we are working on improving Github’s documentation at the moment.

What does MawKit offer?

MawKit includes platform-specific implementation for features like:

  • Leaderboards and achievements (Google Play Games on Android and GameCenter on iOS/OS X).
  • Ads (Admob and AdColony on both iOS and Android – noop implementation for OS X as there is no oficial SDK for this platform).
  • In-app purchases.

As well as cross-platform utilities like:

  • Mathematical helpers (random number generator, ranges).
  • A simple key-value database with local persistence.
  • Additional FiniteTimeActions (move a node to the position of a different node, regardless it is static or in movement, shake a node, etc).
  • Logging utilities (prepending prefixes to the logged message to easily identify their priority)
  • Infinite parallax nodes (both vertical and horizontal).
  • Device utilities (get screen’s size, hardware performance and motion sensors coming soon).
  • Fabric‘s Answer (all platforms) and MixPanel (iOS) support.

Here are some nice snippets:

  • Storing money with KVDatabase:
  • Reporting new score:
  • Checking whether an achievement is unlocked:
  • Showing an ad:
  • Throwing a dice:
  • Moving a node to the position of another moving node (bonus: this snippet is part of Hop Raider):
  • Getting current language:

Ideas, suggestions, contributions…

… are welcomed as Github issues or pull requests.

 

 

Fixing Cocos2d-x glitches with pixel art games

While developing Hop Raider we found a rare glitch in floor’s tiles: sometimes they had an additional semi-transparent border line which was not supposed to be there. We discovered that some sprites were taking a bigger bounding box than they were supposed to, so when a sprite was drawn an additional line taken from adjacent sprites in the spritesheet was also drawn.

If you look carefully (or not so carefully) to the rock base floor in Hop Raider 1.2.1 or older you can see this glitch. It happens in lava tiles too. And this glitch is iOS/Android-independent. This usually happens in rock base floor, lava and sometimes in right-side dirt floors.

As it was somehow random (and actually it didn’t impact in gameplay and didn’t break overall game experience) we didn’t prioritise fixing this glitch but today I have been able to fix it and wanted to share both, the reason of and the solution to the problem.

We were working on a 1080×1920 px canvas and scaling to each device size on runtime. This helps us with the design and development as we can focus just on one resolution and Cocos2d-x adapts it to wherever the game is running. We wanted to show at least the entire width of the canvas as this is a vertical scroll game and out-of-bounds content will be shown as soon as you move up and camera follows you there so we are scaling in a way that the entire horizontal axis will be draw regardless screen proportion or resolution, so Cocos2d-x has to scale and crop (actually this is not necessary) the content.

Scaling is an ambiguous task. Our tiles have a 90×90 px size, so we can fit 12 tiles in horizontal axis. When the canvas is rendered in a 750×1334 px screen (iPhone 6) we are also rendering 12 tiles per row but each tile has a 62.5×62.5 px size. Note that I am operating here at pixel level, so no retina resolution could help us: we are trying to render a sprite that uses half a pixel.

Cocos2d-x (actually OpenGL) has to choose how to handle this situation as we cannot draw half a pixel. The default behaviour is to interpolate the color of that pixel taking into account neighbouring pixels, and the result is a line that is not really what we wanted. In fact we want a much simpler behaviour: ignore that half pixel!

This can be achieved setting each sprite’s texture’s wrap mode to GL_CLAMP_TO_EDGE:

Bonus: setting texture’s minification and magnification filters to GL_NEAREST will prevent Cocos2d-x from blurring pixel-art when scaling it up and down.

App Store review frustrations

Today a Hop Raider‘s update was rejected and I remembered my latests experiences with App Store review. I decided to write about three of them and share my frustrations so neither I nor you feel alone when your app is rejected for apparently no good reason.

River Bunch pricing

River Bunch App Store statuses

Last year I was working on River Bunch, a game for iOS where you are a lizard who ha
s to protect its eggs, preventing some mosquitos from stealing them; an easy game for casual players. At some point in development I needed to transfer the game from an Apple Developer account to a different one. I look for the Transfer app button in iTunes Connect because I had previously seen it but I couldn’t find it then.

It turned out that the Transfer app button was enabled only in apps that where published on the AppStore at least once. River Bunch wasn’t and in fact it wasn’t ready to be published at that moment so I decided to submit it to the App Store as it was (a playable but unfinished game) with an incredibly high price (999$) so no one would download the App. As soon as it was published on the App Store I would initiate the transfer and took it down. Easy, right?

App Store review team didn’t like my approach and rejected River Bunch. The reason was they have questions about app’s metadata, specifically about pricing: they asked if I made a mistake putting that price. I explained the situation and was told to put the intended final price (free), resubmit it (waiting for review again) and then removing it from store quickly before no one downloaded the app.

Frustrating as transferring the app to the new Apple Developer account would have been a much simpler and quicker solution, but I was not offered that possibility. Another easy solution would have been just approving the app with that price but again it was not an option.

Placeholder AppExtra: another thing you can’t do without a previously binary approved is… deleting the app. Yeah, you can remove an app form iTunes Connect if you have a binary approved but if you were just playing around and registered apps you weren’t planning to publish later you’ll end up with placeholder icon and random names taking space in your iTunes Connect dashboard.

Caff picture in picture

Later last year I was working on a Caff update. It added, among other features, support for iOS 9 Picture in Picture playback on iPad. This feature required enabling Audio, AirPlay and Picture in Picture background mode. If this weren’t enabled then Picture in Picture won’t work outside the app, that is, you couldn’t be playing a video and using a different app of browsing your home screen.

App Store review team rejected the update because it was not clear why Caff had enabled Audio, AirPlay and Picture in Picture background mode if it played no audio, regardless the release notes highlighted newly added Picture in Picture support. Fortunately I appealed and explained the reason to have that background mode enabled. My explanation convinced review team and the update was finally approved.

Hop Raider in-app purchases

Hop Raider metadata rejection

My latest experience has been with Hop Raider. In next update I’ve added an in-app purchase to remove ads from the game (interstitial ads that randomly appear when you lose). Again, metadata rejected. Apparently App Store review team couldn’t find the Restore purchases button required to restore non-consumable items buyable in your app.

This one surprised me a lot because that button is right next to the Purchase remove ads button, clearly visible and is featured in the screenshot attached to the in-app purchase (required metadata in iTunes Connect).

I suspect that a fancy feature I added might have been not as great idea as I though it would have been: when player buys or restores the Remove ads in-app purchase the game won’t show Purchase remove ads nor Restore purchases buttons as all purchasable items have already been purchased. In an attempt to not confusing the player I have confused App Store review team.

For the time being I have appealed explaining where is the Restore purchases button and why it might disappear under some circumstances. I’ll update this post as soon as I get news.

Update: App Store review team accepted my explanation and approved this version.

Fixing greyed out songs on iTunes Library

I use iTunes as my main media player and I’m user of iTunes Match since the service was available to Spanish users. It’s a service I really like but recently I’ve experienced an estrange issue: some songs appeared greyed out (even complete albums). I could download them and play them individually but when playing a playlist or album with greyed out songs, iTunes completely skipped them.

Today, thanks to iMore forums, I discovered how to fix this issue.  You have to list all your songs, this can be done following these steps:

  1. Select Music tab on iTunes’ leftmost button bar.
  2. Choose either My Music or Playlists in the middle tab bar.
  3. Open Sort popup by clicking rightmost button in the bar you’ve been interacting with.
  4. Finally, in the dropdown, choose Songs.

You’ll notice that the first column with header has no clear title but a simple check icon. You can customise all the columns but this one, which is always displayed regardless your settings. Checked songs will be playable and unchecked ones won’t. I don’t know why some of my songs where checked and others unchecked neither what really means that a song is checked or not but checking all my songs fixed the issue so, finally, to fix the greyed out issue:

  1. Select all your songs.
  2. Control-click any of them.
  3. On the displayed menu click on Check selection.

Introducing Trakt.tv Browser

I got a 4th gen Apple TV Developer Kit last year in September but I was working full time on Caff and although I wanted to play with it I couldn’t wrote a single app for it before Christmas. Nevertheless I used it for a couple of months, mainly to play media content streamed from my NAS and I missed a way to add movies and TV show to my Trakt.tv watchlist directly from my Apple TV (there are a couple of ‐pretty good‐ media players which sync with Trakt.tv, but none of them allows you to add content to your watchlist).

So I wrote Trakt.tv Browser an extremely simple App that just does it: you can search movies and TV shows and add or remove them from your watchlist. I plan to update it with more features as I use it and find that they are useful but it is a hobby App for the moment so it will take me some time to publish any update.

Let me know any feature you’d like to see in a future update in the comments.

#14617

NewRelic top 5 web transactions by timeI’ve been experiencing higher response times and lower throughput in my server last weeks. I use NewRelic to monitor server’s performance so I found out that queries to /xmlrpc.php were having a gigantic impact in site’s performance.

Googling about that issue I found this post by Hugo Dias about fixing the problem denying access in .htaccess file. However my server doesn’t use apache but nginx so I couldn’t apply that snippet directly. Fortunately porting the snippet to nginx is not so hard with StackOverflow’s help.

CloudFlare, HTTPS and WordPress

Beware: This post was published 2 years ago and its content may be outdated.

Last week I set up HTTPS on this site with CloudFlare’s Flexible SSL so today I’m writing about how did I set it up and what steps you should follow to do so, but first of all let me explain exactly what is CloudFlare Flexible SSL and how it can be free and set up on any website without setting up any SSL certificate. Read more →

When the parody gets real

Beware: This post was published 2 years ago and its content may be outdated.

If you are not Spaniard you might not be aware of this but we have a very unpopular Minister of Education, José Ignacio Wert… and we are going to vote a new government in a few weeks! So as you could expect a lot of “hackers” are trying to get José Ignacio Wert’s Twitter account. But they are not only trying to get @jiwert account but also @wert account, which is, indeed, mine.

How did I get that Twitter handle? Why does it tweet so much? What the hell does it say? Well, today I’ll answer all those questions, so let’s start with a brief review of the past…

Read more →

Naming your partitions

Beware: This post was published 3 years ago and its content may be outdated.

I’ve been playing with different names for partitions on Mac OS X and I’ve found two interesting things:

Spaces in the name

Avoid spaces in the name. At all costs. Some make script are not properly written and don’t work when the partition where the file is located contains a space. Usually the output is something like: HD/Users/sumolari/script.c  not found. OS X uses as default name for system’s partition Macintosh HD. You can easily scape the space using: Macintosh\ HD when writing paths in shell, but some developers don’t worry about that and their scripts just don’t compile. I’ve found this with npm modules that use native code (for instance, ZMQ), as well as Ruby gems (Berkshelf was one of them).

Time Machine

Some months ago I added a solid state disk to my MacBook. I use the typical setup for SSD+HD: I installed OS X in my SSD and moved my user folder to the HD. I enabled Time Machine and I didn’t receive any complain from it, so I kept using it as before.

A few days ago I replaced my HD and when I reinstalled OS X I tried to restore my Time Machine backup. It couldn’t restore my user’s home folder because it was located on a different partition than the system. I was worried but as soon as I logged in my not-restored account (which I moved again to the HD) I run Time Machine and it allowed me to restore all the documents that where there.

Not as clean as a checkbox during OS X installation, but definitively more convenient than losing the files or having to backing them up in other disk before formatting the partition.

Target disk mode

I’ve an iMac and a MacBook. Both of them had only two partitions: SSD and HD. SSD had only OS X and some applications installed and HD had my user account. I started my MacBook in target disk mode and then booted the iMac using MacBook’s SSD partition as boot partition. OS X loaded my user account from iMac’s HD partition, so I had the home folder of my user in the iMac but the applications that were installed on my MacBook. Pretty weird. I finally renamed the partitions to be different on each computer.