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 jGuille

Hi there,

I'm trying to port a simple test game I've made into Android by using CocoonJS.

The problem is that I cant get the touch controlls to work on the apk that CocoonJS generates, while they work perfectly when I try the game from the browser.

This is the code of the main:

ig.module( 
	'game.main' 
)
.requires(
	'impact.game',
	'impact.font',
	
	'plugins.touch-button',
	'plugins.font',
	'plugins.cocoonjs_touchevent_fix',
	
	'game.entities.globo',
	'game.entities.nube_der',
	'game.entities.nube_izq'
)
.defines(function(){

Globo = ig.Game.extend({
	
	// Load a font
	font: new ig.Font( 'media/04b03.font.png' ),
	
	// Clear to white before drawing each frame (default is black)
    clearColor: 'rgb(255, 255, 255)',
	
	buttons: [],
    buttonImage: new ig.Image( 'media/boton.png' ),
	
	init: function() {
		// Initialize your game here; bind keys etc.
		
		//Controles		
		// Prevents spamming of input
      	this.inputDelayTimer = new ig.Timer();
		
        this.buttons = [
        	new ig.TouchButton( 'izq', 0, 400, 80, 80, this.buttonImage, 0 ),
        	new ig.TouchButton( 'der', 240, 400, 80, 80, this.buttonImage, 0 ),
        ];      
		
		//Fondo
		var data = [[1]];
		
		fondo = new ig.BackgroundMap( 240, data, 'media/cielo.png' );
		fondo.repeat = true;
		fondo.preRender = true;
		fondo.setScreenPos( 0, 0 );
		
		//Añado el fondo al array de backgroundMaps, para que el método draw los pinte automáticamente
		this.backgroundMaps.push(fondo);
		
		//Añadir nubes
		this.spawnEntity(EntityNube_der, 240, 400);
		this.spawnEntity(EntityNube_izq, 0, 400);
		
		//Añadir globo
		this.globo = this.spawnEntity(EntityGlobo, 145, 230);
	},
	
	update: function() {
		// Update all entities and backgroundMaps
		this.parent();
		
		// Add your own, additional update code here
	},
	
	draw: function() {
		// Draw all entities and backgroundMaps
		this.parent();
		
		// Add your own drawing code here
		//var x = ig.system.width/2,
		//	y = ig.system.height/2;
		
		//this.font.draw( 'It Works!', x, y, ig.Font.ALIGN.CENTER );
		
		// Draw all touch buttons - if we have any
        if ( this.buttons ) {
			for( var i = 0; i < this.buttons.length; i++ ) {
				this.buttons[i].draw();
			}
      }
	}
});

var c = document.createElement('canvas');
c.id = 'canvas';
document.body.appendChild(c);

ig.main( '#canvas', Globo, 60, 320, 480, 2 );

});

The index.html is this:

<!DOCTYPE html>
<html>
<head>
	<meta name="apple-mobile-web-app-capable" content="yes" />
	<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
	<title>Impact Game</title>
	<style type="text/css">
		html,body {
			background-color: #333;
			color: #fff;
			font-family: helvetica, arial, sans-serif;
			margin: 0;
			padding: 0;
			font-size: 12pt;
		}
		
		#canvas {
			position: absolute;
			left: 0;
			right: 0;
			top: 0;
			bottom: 0;
			margin: auto;
		}
	</style>

	<script type="text/javascript" src="lib/impact/impact.js"></script>
	<script type="text/javascript" src="lib/game/main.js"></script>
</head>
<body>
</body>
</html>

As you can see, I'm using the touch-button plugin plus a fix, but it didn't served.

I hope you can help me, and thanks for the interest in advance. :)

1 decade ago by alexrikelme

Up! I'm interested.

1 decade ago by bea

I'm having trouble with this issue. I would like to upload my game to google play but the touch it doesn't work. My game is completed and i have this problem right now!!

I'm ussing plugins.touch-button and plugins.cocoonjs_touchevent_fix, and it doesn't work...
please help!
Page 1 of 1
« first « previous next › last »