Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by Jon123

I've been trying to convert the physics demo into an apk using cocoonjs, which involved coding the canvas using js instead of putting it in the index.html file:

var obj = document.getElementById('game')
var c = document.createElement('canvas');
c.id = 'canvas';
obj.appendChild(c);

var b1 = document.createElement('div');
b1.id = 'buttonLeft';
b1.className  = 'button';
obj.appendChild(b1);

var b2 = document.createElement('div');
b2.id = 'buttonRight';
b2.className  = 'button';
obj.appendChild(b2);

var b3 = document.createElement('div');
b3.id = 'buttonShoot';
b3.className  = 'button';
obj.appendChild(b3);

var b4 = document.createElement('div');
b4.id = 'buttonJump';
b4.className  = 'button';
obj.appendChild(b4);

The problem is that the touch buttons don't appear on the phone, you can touch anywhere on the screen though and the jetpack guy boosts...

Anyone know where I am going wrong?
Thanks

1 decade ago by dominic

I'm not sure how CocoonJS handles those additional HTML elements, but I think you still have to position those buttons somehow and also set their appearance.

However, I would advise you to ditch those additional HTML elements completely and go with the Touch Button plugin: http://impactjs.com/ejecta/integrating-impact-games#touch-buttons

1 decade ago by Jon123

Thanks Dominic,

I didn't realise the jumpnrun example catered for this. I've got it to work with that so will have a go re-factoring my game a bit.

1 decade ago by y0ungb0b

I think Cocoon will throw errors/warnings in its console if it comes across things it doesn't support.
Page 1 of 1
« first « previous next › last »