Browsing the Phone Gap category

jQuery: avoid reading the DOM when possible

I was working on a mobile game in jQuery.  Specifically, I was working on “collision detection” – when the hero of my game touched an enemy.  I was extracting the position of the hero (a DIV element) and comparing that to the position of every enemy on the screen (I was using jQuery to loop through all elements with a certain class).
The more efficient way was to store the (x,y) coordinates in a variable (perhaps you might want to use an array).
By looping through the array to compare the positions, I saw a noticeable improvement on my phone (notsomuch on my desktop).
I was reading a book that said something along  the lines of “avoid reading the DOM like the plague” – and it was right!

Read the article

PhoneGap Version mismatch

While making an app using PhoneGap (for iOS), I got this error:

Version Mismatch.

Neither CFBundleVersion [1.00′] nor CFBundleShortVersionString[”] in the Info.plist match the version of the app set in iTunes Connect [‘1’]

 The solution: update the XML configuration file to reflect the right version of your app.  This was a similar problem I had similar to when I was trying to update the .APK in the Android version  of my app.

Read the article

“An error occurred uploading to iTunes store”

I finally finished my iOS (iPhone/iPad) app, using PhoneGap, got the certificates to authenticate, and I had to upload my file (“binary”) to Apple.  But I got an error, simply “an error occurred uploading to the iTunes store“.  I was using xcode 4.3.2
The solutions I found were to do a “Software Update” (by clicking the “Apple Symbol”).  I did this for both XCode and Application Loader; didn’t work.  Then I did it for everything else.  Other solutions said that the Java version was too new – I couldn’t find I had Java, so I installed it, then downgraded the version.
At one point I revoked my certificate.  I didn’t know if because I had 2 certificates with the same name, if that was an issue.  But the email from Apple saying that it was revoked and thus nothing could be processed went to my spam folder, so I don’t know if I was trying to submit (some of the time – certainly not the entire time) an app that wouldn’t go through.
I finally solved it!  I had to update the “Application Loader” program.  Even though I tried to do the “Software Update” while in “Application Loader,” it didn’t work.  I updated from Application Loader 2.5.2 to the latest version: currently 2.9.1.  I did this by going to iTunes Connect >> Manage Apps >> link to download.  After installing the updated version, I was able to successfully submit to the Apple App store!
UPDATE: I had to submit an “update” to the iTunes store, and still received this error.  I had gone into XCode and opened up “Application Loader” from the “Open Developer Tool” section.  Looking closer, apparently I had 2 versions of the “Application Loader” on my computer, as I was still trying to upload with the out-dated version.  I used the “spotlight” to ensure I had the right one open.  Then it uploaded correctly – again, make sure you’re using the right version!

Read the article

Playing audio with HTML5 doesn’t work on mobile – not even with PhoneGap

This is still an unresolved issue.
I have an app (website in an app shell) that plays sound, triggered from a javascript event.  This isn’t just background music playing constantly when the pages loads up: there’s a specific event that’s causing the sound to play (a sound effect).  It works on my desktop computer (in various browsers), but does not work on my mobile devices (Android, iPod) or tablet (iPad).
I searched a lot, and came across something that Apple put (in iOS) to not allow sounds to play by default, without the user explicitly allowing it.  That makes sense.  I’m working on a mobile app, with PhoneGap (specifically, “PhoneGap Build” – where you upload a zip file), so I was hoping there was a work-around.  Apparently there’s a plug-in, but I couldn’t figure out how to activate it (all the websites were referring to “java” – and not updating the “config.xml” file for a HTML/Javascript app).
What’s more, is that when the sound was in the app, I was unable to re-start the app (i.e. after I closed the app, and I re-opened it, I got the error:
Phonegap – “Application Error: The connection to the server was unsuccessful. (file:///android_asset/www/index.html)
by removing the javascript that preloaded (and played) the sound – seeing as how I couldn’t get it to work anyways – that got rid of this error.  Lots of solutions involved creating a “main.html” and have the regular index.html redirect (via window.location) to the new page, but I didn’t have to do that.
Guess my game won’t have sound (yet)!

Read the article

jQuery Game Essentials – Sound example for HTML5

I’m reading the book “jQuery Game Essentials” to make my next web app (HTML5/jQuery).  The book is very helpful!  The last chapter focuses on adding “sound” to the game, but I had trouble implementing their solution.

I’m going with the “HTML5 Audio Element” route – where I would have both an .mp3 and .ogg format of my sounds.

The first problem was that, even though the book is excellent, there was a small typo: Under “Playing and Stopping Sounds”, there is a line: if ( === undefined){

But it should read if ( === undefined){

(note, “loop” was spelled wrong). While I didn’t check, I bet it was probably fixed/noted in the book’s erratta .

But that was just the initial problem. I’m not too familiar with object oriented programming, so I didn’t know how to call it.
First, you have to preload the sounds already. Put this in your “game initialize,” or in my case, simply the document.ready() –

$( document ).ready(function() {

sound_explosion = new sound();


Note that I’m not specifying the extension (.mp3 / .ogg), since that will be determined in the javascript code.

Anyways, the part where you actually want the sound to play, specify:;

Note: you could put that right after preloading the sound if it was for background music. I specified “false” (and put the code somewhere else) since I wanted it to play once, for a sound effect.

See also my article on where you can download free game sound effects in mp3 format

The full javascript file I’m using is as follows:


// a sound object
sound = function(){

// Preloads the sound
this.preload = function(url){ = new Audio(); = “auto”; = url + sound.ext;;

// Returns true if the sound is preloaded
this.isPreloaded = function(){
return ( == 4)

// Starts to play the sound. If loop is true the
// sound will repeat until stopped = function(loop){
if ( === undefined){‘ended’, function() {
this.currentTime = 0;;
}, false);
} else { = loop;

// Stops the sound
this.stop = function(){; = 0;

// Pauses the sound
this.pause = function(loop){;

var audio = new Audio();
var canPlayOggVorbis = audio.canPlayType(‘audio/ogg; codecs=”vorbis”‘);
var canPlayMP3 = audio.canPlayType(‘audio/mpeg; codecs=”mp3″‘);
if (canPlayOggVorbis == “probably” || (canPlayOggVorbis == “maybe” && canPlayMP3 != “probably”)) {
sound.ext = “.ogg”;
} else {
sound.ext = “.mp3”;


Read the article

download free video game sound effects mp3

I’m working on a mobile game and I did a LOT of searching for various references to free video game sound effects – specifying things like “power ups”, or just being in general.  I had such a hard time finding any! I’m going the route of “mp3/ogg” route, so I wanted to download an mp3 and just convert it after.

While I could do “keyword stuffing” here (black hat SEO), I’ll leave out the various terms I searched for, and just say that I ended up (surprisingly) finding the sound effects at http://www.flashkitcom.

I originally found the link from 55 Great Websites To Download Free Sound Effects on Hong Kiat

Read the article

Conjecture! Free mobile app – puzzle game

Many of my recent posts have been regarding my first mobile game: Conjecture! – it’s a puzzle game, similar to MasterMind.

I used PhoneGap (and jQuery) to make both the Android and iOS versions.

Read the article

how long does it take for Apple to approve an app

I recently made an iPhone app (really, iPod/iPhone/iPad – all iOS… using PhoneGap).  Apple has to “approve” all apps.

The time it took to approve was about 4 days!  This is early April 2014.

The initial upload/approval took about a week; maybe because I submitted it on  a Thursday, and there was a weekend in between? But in my “update,” I submitted it on Monday night and it was approved Friday afternoon.

I came across which has more data points and would be more reliable than my experiences… but it’s good to know that (for updates at least), that an app could be approved within a week.

Read the article

jquery mobile ipad disable bounce effect but scroll

For my mobile app (made using PhoneGap), I wanted a way to disable the “bounce” affect, but keep the scrolling capability.  I found the javascript to disable the “bounce” affect, but I needed my container (in the center of the screen – not the header/footer) to scroll.  It turns out you can’t really do this with javascript; the solution I ended up with was a preference setting in PhoneGap:

<preference name=”UIWebViewBounce” value=”false” /> <!– disable iOS “bounce” –> 

<preference name=”DisallowOverscroll” value=”true”/> <!– disable iOS “bounce” –>

(I’m not sure if both lines are needed?).  I spent a good long while trying to do it in Javascript; only to find out that it can’t be done – but PhoneGap does allow for a way to enable this.

Read the article

how long does it take for Apple to approve an iPhone/iPad app in the itunes store?

I finished my iOS (iPhone/iPad) app!  I submitted it to the Apple store, and had to just wait.  The app goes through various phases (“Waiting for Review,”  “In Review,” and finally, “Ready For Sale”).

How long did it take?  As of late March 2014: about a week.  I submitted it on a Thursday night and then it was “Ready for Sale” the following Wednesday.  (While writing this, I was thinking if I had to account for weekends, but I suppose it’s all relative: if you submitted it on a Monday, you’d still probably have to wait a week).  Granted, I do not know the schedule of the Apple employees who have to review it.

Once it did get approved, Apple says it could take 24 hours for it to actually appear in the store.  I don’t really have a benchmark for how long it actually takes; I’m just constantly refreshing the iTunes Link Maker to see when my app appears.

Read the article