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 TObe

Hi, I'm trying to run my game in iOS but when I try to run the game in the simulator says that can't load one of the entities. Here's is the main.js and the entity that I'm trying to load:

ig.module( 
	'game.main' 
)
.requires(
	'impact.game',
	'impact.font',
	
	'plugins.director.director',
	
	'game.entities.player',
	'game.entities.spike',
	'game.entities.distComidaAnimal',
	'game.entities.changuito',
	'game.entities.reja',
	'game.entities.visitante',
	'game.levels.titulo',
	'game.levels.test',
	'plugins.ios.ios'
)
.defines(function(){

MyGame = ig.Game.extend({
	
	gravity: 0, // All entities are affected by this
	
	// Load a font
	font: new ig.Font( 'media/04b03.font.png' ),
	
	// timer de distractor
	timerDistractor: new ig.Timer(),
	timerFijadorDistractor: new ig.Timer(),
	
	// timer de visitantes
	timerVisitante: new ig.Timer(),
	
	init: function() {
		//if( ios ) { 
		    // When the 'ios' object is defined, we're running 
		    // inside iOSImpact
		    
		    // Define an area of the screen as button. The syntax is:
		    // x, y, width, height, action
		    ig.input.bindTouchArea( 0, 224, 80, 96, 'left' );
		    ig.input.bindTouchArea( 80, 224, 80, 96, 'right' );
		    ig.input.bindTouchArea( 160, 224, 160, 96, 'up' );
		    ig.input.bindTouchArea( 240, 224, 240, 96, 'down' );*/
		}else{
			// Bind keys
			ig.input.bindTouch( '#buttonLeft', 'left' );
			ig.input.bindTouch( '#buttonRight', 'right' );
			ig.input.bindTouch( '#buttonUp', 'up' );
			ig.input.bindTouch( '#buttonDown', 'down' );
		}
		
		// Load the LevelTest as required above ('game.level.test')
		this.loadLevel( LevelTest );
		
		this.myDirector = new ig.Director(this, [LevelTitulo, LevelTest]);
		
		this.rejaRota = 0;
		this.timerDistractor.set( 10 );
		this.timerFijadorDistractor.set( 5 );
		this.timerVisitante.set((Math.random()*10)*2);
		
		// variables globales y banderas
		nuevoDistractor = false;
		this.titulo = 0;
		dinero = 0;
		felicidad = 50;
	},
	
	update: function() {	
		// screen follows the player
		var player = this.getEntitiesByType( 'EntityPlayer' )[0];
		
		var distractores = ig.game.getEntitiesByType( 'EntitySpike' );
		if(this.titulo == 0){
			if( ig.input.pressed('left') ){
				this.myDirector.nextLevel();
				this.titulo = 1;
			}
		}
		if(distractores.length){
			// colocar el distractor
			distractores[distractores.length - 1].activo = true;
		}
		
		
		// pinta distractores
		if(this.timerDistractor.delta() >= 0 && this.titulo == 1){
			ig.game.spawnEntity( EntitySpike, 125, 130, {flip:this.flip} );
			this.timerDistractor.reset();
			nuevoDistractor = true;
		}
		
		// fija distractor
		if(this.timerFijadorDistractor.delta() >= 0){
			nuevoDistractor = false;
			this.timerFijadorDistractor.reset();
		}
		
		// pinta visitantes
		if(this.timerVisitante.delta() >= 0 && this.titulo == 1){
			ig.game.spawnEntity( EntityVisitante, 145, 74, {flip:this.flip} );
			this.timerVisitante.reset();
			dinero += 5;
		}
		
		// Update all entities and BackgroundMaps
		this.parent();
	},
	
	draw: function() {
		// Draw all entities and BackgroundMaps
		this.parent();
		
		this.font.draw( 'Zoo Keeper Beta', 50, 10 );
		if(this.titulo == 0){
			this.font.draw( 'Presiona TESTIzquierda', 50, 18 );
			this.font.draw( 'para comenzar', 50, 26 );
		}
	}
});


// Start the Game with 60fps, a resolution of 240x160, scaled
// up by a factor of 2
if( ig.ua.mobile ) {
// Disable sound for all mobile devices
ig.Sound.enabled = false;
}

if( ig.ua.iPhone4 ) {
// The iPhone 4 has more pixels - we'll scale the 
// game up by a factor of 4
ig.main('#canvas', MyGame, 60, 160, 160, 4);
}
else if( ig.ua.mobile ) {
// All other mobile devices
ig.main('#canvas', MyGame, 60, 160, 160, 2);
}
else {
// Desktop browsers
ig.main('#canvas', MyGame, 60, 160, 160, 4);
}


});


Entity:

ig.module(
	'game.entities.changuito'
)
.requires(
	'impact.entity'
)
.defines(function(){
	
EntityChanguito = ig.Entity.extend({
	size: {x: 9, y: 14},
	maxVel: {x: 75, y: 75},
	friction: {x: 150, y: 0},
	
	type: ig.Entity.TYPE.B, // Evil enemy group
	checkAgainst: ig.Entity.TYPE.A, // Check against friendly
	collides: ig.Entity.COLLIDES.PASSIVE,
	
	health: 2700,
	loco: 0,
	speed: 14,
	flip: true,
	conteoInicial: 0,
	
	animSheet: new ig.AnimationSheet( 'media/changuito.png', 9, 14 ),
	
	timer: new ig.Timer(),
	timerStandBy: new ig.Timer(),
	
	init: function( x, y, settings ) {
		this.parent( x, y, settings );
		
		this.addAnim( 'standby', 0.1, [0,1] );
		this.addAnim( 'run', 0.1, [0,1,2,3] );
		this.anims.run.flip.x = true;
		this.anims.run.flip.y = true;
		this.timerStandBy.set( 15 );
		this.timer.set( 5 );
		this.moviendose = 0;
	},
	
	
	update: function() {
		var aleatorioX = Math.random() < 0.5 ? -1 : 1;
		var aleatorioY = Math.random() < 0.5 ? -1 : 1;
		if(this.moviendose == 0){
			var velAleatoriaX = Math.floor(Math.random()*41)
			var velAleatoriaY = Math.floor(Math.random()*41)
		}
		var tiempoRandom = Math.floor(Math.random()*11)
		if(this.conteoInicial == 0){
			//Obtiene la cantidad inicial de rejas. Osea reja completa
			this.cantRejas = ig.game.getEntitiesByType( 'EntityReja' ).length;
			this.conteoInicial = 1;
		}
		var cantidad = ig.game.getEntitiesByType( 'EntityDistComidaAnimal' ).length;	
    	// en caso que haya distractores
    	if(cantidad > 0 && this.loco == 0){
    		var distractor = ig.game.getEntitiesByType( 'EntityDistComidaAnimal' )[cantidad-1];
    		var distancia = this.distanceTo(distractor);
        	
        	var indice = 0;
        	var indiceFinal = cantidad-1;
        	
        	for(indice=0;indice<cantidad;indice++){
        		distractor = ig.game.getEntitiesByType( 'EntityDistComidaAnimal' )[indice];
        		if(distancia > this.distanceTo(distractor)){
        			distancia = this.distanceTo(distractor);
        			indiceFinal = indice;
        		}
        	}
        	
        	var distractorFinal = ig.game.getEntitiesByType( 'EntityDistComidaAnimal' )[indiceFinal];
        	var angulo = this.angleTo(distractorFinal);
        	
    	}
    	if( this.cantRejas > ig.game.getEntitiesByType( 'EntityReja' ).length){
			//Aquí se debe de mover como loco el changuito
    		this.vel.x = this.maxVel['x'] * aleatorioX;
    		this.vel.y = this.maxVel['y'] * aleatorioY;
    		this.loco = 1;
		}else{
			//Aquí debe de ir el movimiento de un changuito enjaulado
			if(distancia > 0){
	        	this.vel.x = velAleatoriaX * Math.cos(angulo);
	        	this.vel.y = velAlearoriaY * Math.sin(angulo);
			}else if(this.timer.delta()){
				moviendose = 1;
				this.vel.x = velAleatoriaX * aleatorioX;
	    		this.vel.y = velAleatoriaY * aleatorioY;
				//var xdir = 0;
				//var ydir = this.flip ? -1 : 1;
				//this.vel.x = this.speed * xdir;
				//this.vel.y = this.speed * ydir;
				this.timerStandBy.reset();
			}else{
				this.vel.x = 0;
				this.vel.y = 0;
				if(this.timerStandBy.delta() > 0){
					this.timer.set(tiempoRandom);
					this.moviendose = 0;
				}
			}
		}
		this.parent();
	},
	
	
	handleMovementTrace: function( res ) {
		this.parent( res );
		
		// collision with a wall? return!
		if( res.collision.x ) {
			this.flip = !this.flip;
			this.anims.run.flip.x = !this.anims.run.flip.x;
		}if( res.collision.y ) {
			this.flip = !this.flip;
			this.anims.run.flip.y = !this.anims.run.flip.y;
		}
	},	
	
	check: function( other ) {
		other.receiveDamage( 10, this );
	}
});

});

1 decade ago by Joncom

Would you mind supplying the error exactly as you received it?

1 decade ago by TObe

objc[773]: Class ProfilerServer is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/System/Library/PrivateFrameworks/JavaScriptCore.framework/JavaScriptCore and /Users/Eder/Library/Application Support/iPhone Simulator/5.1/Applications/0918375A-02A1-4E19-AC38-1EAE594FB0F9/iOSImpact.app/iOSImpact. One of the two will be used. Which one is undefined.
2012-08-19 14:08:36.867 iOSImpact[773:c07] Loading Script: ios-impact.js
2012-08-19 14:08:36.869 iOSImpact[773:c07] Loading Script: index.js
2012-08-19 14:08:36.870 iOSImpact[773:c07] Loading Script: lib/impact/impact.js
2012-08-19 14:08:36.872 iOSImpact[773:c07] Loading Script: lib/game/main.js
2012-08-19 14:08:36.879 iOSImpact[773:c07] Loading Script: lib/impact/loader.js
2012-08-19 14:08:36.880 iOSImpact[773:c07] Loading Script: lib/impact/system.js
2012-08-19 14:08:36.881 iOSImpact[773:c07] Loading Script: lib/impact/input.js
2012-08-19 14:08:36.882 iOSImpact[773:c07] Loading Script: lib/impact/sound.js
2012-08-19 14:08:36.901 iOSImpact[773:c07] Loading Script: lib/impact/game.js
2012-08-19 14:08:36.902 iOSImpact[773:c07] Loading Script: lib/impact/font.js
2012-08-19 14:08:36.903 iOSImpact[773:c07] Loading Script: lib/plugins/director/director.js
2012-08-19 14:08:36.904 iOSImpact[773:c07] Loading Script: lib/game/entities/player.js
2012-08-19 14:08:36.905 iOSImpact[773:c07] Loading Script: lib/game/entities/spike.js
2012-08-19 14:08:36.906 iOSImpact[773:c07] Loading Script: lib/game/entities/distComidaAnimal.js
2012-08-19 14:08:36.911 iOSImpact[773:c07] Can't load Script: lib/game/entities/changuito.js
2012-08-19 14:08:36.912 iOSImpact[773:c07] Loading Script: lib/game/entities/reja.js
2012-08-19 14:08:36.913 iOSImpact[773:c07] Loading Script: lib/game/entities/visitante.js
2012-08-19 14:08:36.914 iOSImpact[773:c07] Loading Script: lib/game/levels/titulo.js
2012-08-19 14:08:36.915 iOSImpact[773:c07] Loading Script: lib/game/levels/test.js
2012-08-19 14:08:36.916 iOSImpact[773:c07] Loading Script: lib/plugins/ios/ios.js
2012-08-19 14:08:36.917 iOSImpact[773:c07] Loading Script: lib/impact/image.js
2012-08-19 14:08:36.919 iOSImpact[773:c07] Loading Script: lib/impact/timer.js
2012-08-19 14:08:36.920 iOSImpact[773:c07] Loading Script: lib/impact/entity.js
2012-08-19 14:08:36.942 iOSImpact[773:c07] Loading Script: lib/impact/collision-map.js
2012-08-19 14:08:36.944 iOSImpact[773:c07] Loading Script: lib/impact/background-map.js
2012-08-19 14:08:36.945 iOSImpact[773:c07] Loading Script: lib/plugins/ios/animation.js
2012-08-19 14:08:36.946 iOSImpact[773:c07] Loading Script: lib/plugins/ios/input.js
2012-08-19 14:08:36.947 iOSImpact[773:c07] TypeError: 'undefined' is not a function (evaluating 'ig.Input.inject') at line 69 in lib/plugins/ios/input.js
2012-08-19 14:08:36.947 iOSImpact[773:c07] Loading Script: lib/plugins/ios/font.js
2012-08-19 14:08:36.948 iOSImpact[773:c07] TypeError: 'undefined' is not a function (evaluating 'ig.Font.inject') at line 41 in lib/plugins/ios/font.js
2012-08-19 14:08:36.948 iOSImpact[773:c07] Loading Script: lib/plugins/ios/image.js
2012-08-19 14:08:36.949 iOSImpact[773:c07] TypeError: 'undefined' is not a function (evaluating 'ig.Image.inject') at line 56 in lib/plugins/ios/image.js
2012-08-19 14:08:36.949 iOSImpact[773:c07] Loading Script: lib/plugins/ios/loader.js
2012-08-19 14:08:36.950 iOSImpact[773:c07] TypeError: 'undefined' is not a function (evaluating 'ig.Loader.inject') at line 28 in lib/plugins/ios/loader.js
2012-08-19 14:08:36.950 iOSImpact[773:c07] Loading Script: lib/plugins/ios/system.js
2012-08-19 14:08:36.951 iOSImpact[773:c07] TypeError: 'undefined' is not a function (evaluating 'ig.System.inject') at line 56 in lib/plugins/ios/system.js
2012-08-19 14:08:36.951 iOSImpact[773:c07] Loading Script: lib/impact/animation.js
2012-08-19 14:08:36.952 iOSImpact[773:c07] TypeError: 'undefined' is not a function (evaluating 'ig.Animation.inject') at line 45 in lib/plugins/ios/animation.js
2012-08-19 14:08:36.954 iOSImpact[773:c07] Loading Script: lib/impact/map.js
2012-08-19 14:08:36.954 iOSImpact[773:c07] Unresolved (circular?) dependencies: game.main at line undefined in undefined
Page 1 of 1
« first « previous next › last »