Migration from gameQuery 0.3.x to 0.4.x

This small guide will help you migrate you code to gameQuey 0.4.x, however it will not cover sound since support prior 0.4.0 was mosty anecdotal.

Animation declaration

gameQuery 0.4.0 is more eco-friendly, it doesn’t polute the global scope with stuff anymore! But that as a price: you cannot just refer to Animation anymore. Instead you will have to go through the jQuery namespace $ and trought the gameQuery namespace. The place where the constantes describing the type of animation where stored has change to: they where in Animation and are now in $.gameQuery. The examples that follow will sum this up:

gameQuery 0.3.x
var myAnimation = new Animation({ imageURL: “myImage.png”, delta: 70, numberOfFrame: 10, rate: 30, type: Animation.VERTICAL });
gameQuery 0.4.x
var myAnimation = new $.gameQuery.Animation({ imageURL: “myImage.png”, delta: 70, numberOfFrame: 10, rate: 30, type: $.gameQuery.ANIMATION_VERTICAL });

This shouldn’t be to complicated to do with two simple replace: 1st replace all new Animation with new $.gameQuery.Animation and then replace any Animation. with $.gameQuery.ANIMATION_.

playground()

The playground function was somewhat strange when compared to standard jQuery functions. Now it works like you may expect: call it on a selected element to make it the playground and pass option as the first argument. I you need to retrieve it later just call $.playground()

gameQuery 0.3.x
$().playground(“#playground”, { height: PLAYGROUND_HEIGHT, width: PLAYGROUND_WIDTH }) … $().playground().addSprite(…);
gameQuery 0.4.x
$(“#playground”).playground({ height: PLAYGROUND_HEIGHT, width: PLAYGROUND_WIDTH }) … $.playground().addSprite(…);

Sadly this is not as easy to automate as the Animation. However there should’nt be that many place where you use playground() to define you playground so you could do this part by hand and replace all remaining instances of $().playground() by $.playground().

New default values

The default value of the delta option for Animation as been changed to a rather random 32 to a more logical 0. This is very unlikley that this will affect you in any way.

setLoadBar()

This is not a change that will break your code but you should be aware that you can now give as a seconde argument to the setLoadBar methode a function. It will be called at each time a progress as been made and be given as first and only arguement the percentage of progession.

This function is somewhat strange, like playground() use to be so it may well be rewriten at some point

$().setLoadBar(“#myLoadBar”, 400, function(percent){ $(“#percentIndicator”).html(“”+percent+”%”); });
Fork me on GitHub