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

9 years ago by BlairH

I have a every simple game that I am currently developing. It is just a basic spaceship shooter.

I have four screens:
Title/Opening
Game
Winner
Lose

I am using the touch button add-in to place buttons on the screen for up,down and shoot.

On the desktop I am using spacebar, up arrow and down arrow.

This problem that I am having is with the mobile version. When I run it in the simulator I get the buttons, but they will not bind with the up,down and shoot functions.

Main.js
init: function() {
	
		console.log('Step 2');
		
		if(ig.ua.mobile){
		this.buttons = new ig.TouchButtonCollection([
		new ig.TouchButton('up', {left:0, bottom:0}, 70,75,this.buttonImage, 0),
		new ig.TouchButton('down', {left:128, bottom:0}, 70,75,this.buttonImage, 1),
		new ig.TouchButton('fire', {right:128, bottom:0}, 70,75,this.buttonImage, 2)
		]);
		
		this.buttons.align();
		console.log('Step 3');
		}
		else
		{
		ig.input.bind( ig.KEY.UP_ARROW, 'up' );
		ig.input.bind( ig.KEY.DOWN_ARROW, 'down' );
		ig.input.bind(ig.KEY.SPACE, 'fire');					
		}
		
		this.loadLevel( LevelMain );

It binds fine with the desktop functions.

It also works fine if I go directly into MyGame - rather than the Opening title screen.

I have put a few console.log checks in and they all are working as expected.

Any help would be appreciated.

Thanks,

9 years ago by Joncom

So when you click touch buttons on mobile, the input events (up, down, shoot, etc.) do not fire? However, if you load "MyGame" first instead of "Opening title screen", then they fire correctly?

It sounds like maybe your title screen is its own instance of ig.Game? If that&039;s true, then you'd need to bind the input there too, not just in #MyGame.

9 years ago by BlairH

Thanks, I had a break through this morning.

You were correct, made the change and all is well and working as expected.
Page 1 of 1
« first « previous next › last »