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 richardelms

Hi Guys

I have followed the documentation but my buttons do not seem to pay attention to the anchor settings.

They are all drawn on top of each other in the top left of the screen.

 this.buttons = new ig.TouchButtonCollection([
                new ig.TouchButton( 'left', {left:  0, bottom: 0}, 40, 48, this.buttonImage, 0 ),
                new ig.TouchButton( 'right', {left: 48, bottom: 0}, 40, 48, this.buttonImage, 1 ),
                new ig.TouchButton( 'shoot', {right: 48, bottom: 0}, 40, 48, this.buttonImage, 2 ),
                new ig.TouchButton( 'jump', {right: 0, bottom: 96}, 40, 48, this.buttonImage, 3 )
            ]);  

No matter what I change the buttons are always drawn in the top left.

Any ideas?

Thanks

Rich

1 decade ago by richardelms

This is how I am launching the game

var height = 214;
var scale = window.innerHeight / height;
var width = window.innerWidth / scale;

canvas.style.width = window.innerWidth;
canvas.style.height = window.innerHeight;

ig.System.scaleMode = ig.System.SCALE.CRISP;

ig.main('#canvas', MyGame, 60, width, height, 1);

1 decade ago by stillen

I made this suggestion before but it fell on deaf ears. The documentation doesn't say this:
Must be added to the game update function:

this.buttons align();
this.buttons draw();

1 decade ago by richardelms

That worked!

thanks!

1 decade ago by dominic

Sorry for that. Just updated the docs.

Note that you typically only have to align the buttons once (that is, if you don't change the game's screen size).
Page 1 of 1
« first « previous next › last »