ToDo List/Game

ToDo List/Game

Place a description in the Items field and put a time (in minutes) for how long the task will take and click Add Item. When complete, click the Complete button and that will strengthen your character.


Desktop Version      Mobile Version

Player must try to collect the diamond. They can click/touch the screen to create blocks to get to the diamond. Enemies can destroy any created blocks on touch.
Created Blocks can be removed by clicking/touching them again.


Unity Game Tutorial

Wednesday, April 3, 2013

Mobile Success

I got my buttons working on select mobile devices. I tested it on iOS on Safari and Chrome and on Android on the default browser and Chrome. The Android experience was slow, but my test was on an HP Touchpad running Cyanogenmod so I assume it is the hardware/software combination that caused it to be slow since it ran perfectly on my iPhone 5. Since I have all the basic mechanics done, I will be able to start on actual level design and eventually add in enemies.

Here is the basic code for anyone interested:

var j = document.getElementById('jump');

j.addEventListener('touchstart', function(event){ jump(event,true); }, false);
j.addEventListener('touchend', function(event){ jump(event,false); }, false);

function jump(e,bool) {
    if(e.target.localName != 'select'){
    direction.up= bool;

I get the DOM element for the button and set a 'touchstart' and 'touchend' event that calls a function. This function overrides the default highlighting that mobile devices do while the person holds there finger over an element. I then set the direction.up variable to true or false depending on whether it was a start or end event. The player jumps constantly while direction.up is true. This does lead to a problem is a user does not make the touchend event occur, but I will worry about that later. And that is how a button can be done with touch :D

No comments:

Post a Comment