Thanks to both of you for your help.
Great plugin by the way Mike, I actually don't think that Director is the cause of the problem. Here is my main.js file thus far:
ig.module('game.main')
.requires(
'impact.game',
'impact.font',
'plugins.director.director',
'game.entities.player',
'game.entities.crate',
'game.levels.title',
'game.levels.main',
'game.levels.0x0',
'game.lang.load',
'plugins.box2d.game'
)
.defines(function () {
//localization
Lang = enUS;
//the game
MyGame = ig.Box2DGame.extend({
//all entities are affected
gravity: 100,
touches: function (th, buf) {
return (
touch.clientX > th.pos.x - ig.game.screen.x + oL - buf && touch.clientY > th.pos.y - ig.game.screen.y + oT - buf && touch.clientX < (th.pos.x - ig.game.screen.x + oL) + th.size.x + buf && touch.clientY < (th.pos.y - ig.game.screen.y + oT) + th.size.y + buf);
},
//clearColor: '#1b2026',
// Load fonts
h1xlight: new ig.Font('media/h1.font.eee.png'),
h1xdark: new ig.Font('media/h1.font.222.png'),
h2xlight: new ig.Font('media/h2.font.eee.png'),
h2xdark: new ig.Font('media/h2.font.222.png'),
bodyxlight: new ig.Font('media/body.font.eee.png'),
bodyxdark: new ig.Font('media/body.font.222.png'),
STATE: {
GAMEOVER: 0,
GAMEPLAYING: 1,
PLAYERELIMINATED: 2,
BEDROOM: 3,
MENU: 4,
LOBBY: 5
},
init: function () {
//bind keys
ig.input.bind(ig.KEY.LEFT_ARROW, 'left');
ig.input.bind(ig.KEY.RIGHT_ARROW, 'right');
ig.input.bind(ig.KEY.UP_ARROW, 'up');
ig.input.bind(ig.KEY.DOWN_ARROW, 'crouch');
ig.input.bind(ig.KEY.ESC, 'toggleMenu');
ig.input.bind(ig.KEY.SPACE, 'jump');
ig.input.bind(ig.KEY.ENTER, 'enter');
ig.input.bind(ig.KEY.X, 'interact');
ig.input.bind(ig.KEY.C, 'attack');
if( ig.ua.mobile ) {
ig.input.bindTouch( '#buttonLeft', 'left' );
ig.input.bindTouch( '#buttonRight', 'right' );
ig.input.bindTouch( '#buttonShoot', 'shoot' );
ig.input.bindTouch( '#buttonJump', 'jump' );
}
// Initialize your game here; bind keys etc.
this.timer = new ig.Timer(1);
this.eliminatedTimer = new ig.Timer(5);
this.transitionTimer = new ig.Timer(3);
this.screenWidth = 640;
this.screenHeight = 480;
this.currentState = this.STATE.LOBBY;
this.drawCoordinates = {
lives: {
x: ig.system.width - 30,
y: ig.system.height - 10
},
score: {
x: ig.system.width - 50,
y: 0
},
gameover: {
x: ig.system.width / 2,
y: ig.system.height / 2
},
title: {
x: ig.system.width / 2,
y: ig.system.height / 2 - 30
}
}
this.myLevels = new ig.Director(this, [LevelTitle, Level0x0]);
},
drawBackground: function () {
for (var i = 0; i < this.backgroundMaps.length; i++) {
this.backgroundMaps[i].draw();
}
},
isLevelCompleted: function () {
enemyTypes = [EntityEnemyBasic, EntityEnemyBlink, EntityEnemyWide, EntityEnemySpinner, EntityEnemyBase];
for (en = 0; en < enemyTypes.length; en++) {
var enemy = this.getEntitiesByType(enemyTypes[en]);
if (enemy.length > 0) {
return false;
}
}
return true;
},
update: function () {
// Update all entities and backgroundMaps
switch (this.currentState) {
case this.STATE.GAMEPLAYING:
// Check to see if all enemies have been destroyed, every 1 second.
// If they have then transition to the next level. Also check to see
// if the player is out of lives. If so change to player eliminated
// game state.
break;
case this.STATE.PLAYERELIMINATED:
if (this.eliminatedTimer.delta() > 0) {
this.changeState(this.STATE.GAMEOVER);
}
break;
case this.STATE.BEDROOM:
if (ig.input.pressed('enter') || ig.input.pressed('jump')) {
this.changeState(this.STATE.GAMEPLAYING);
}
break;
default:
if (ig.input.pressed('enter') || ig.input.pressed('jump')) {
this.changeState(this.STATE.BEDROOM);
}
break;
}
if (this.currentState != this.STATE.BEDROOM) {
this.parent();
}
// Add your own, additional update code here
},
changeState: function (newState) {
this.currentState = newState;
switch (this.currentState) {
case this.STATE.GAMEPLAYING:
this.timer.reset();
break;
case this.STATE.BEDROOM:
//Advance to next level. If false then we are at the
//end of the levels and need to go back to the first
//playing level.
if (!this.myLevels.nextLevel()) {
this.myLevels.jumpTo(LevelMain);
}
this.transitionTimer.reset();
break;
case this.STATE.PLAYERELIMINATED:
this.eliminatedTimer.reset();
break;
default:
this.myLevels.jumpTo(LevelTitle);
break;
}
},
draw: function () {
// Draw all entities and backgroundMaps
if (this.currentState != this.STATE.BEDROOM) {
// Draw all entities and backgroundMaps
this.parent();
} else {
//In a level transition, therefore draw only the background
this.drawBackground();
}
}
});
if( ig.ua.iPad ) {
ig.Sound.enabled = false;
ig.main('#canvas', MyGame, 60, 240, 160, 2);
}
else if( ig.ua.mobile ) {
ig.Sound.enabled = false;
ig.main('#canvas', MyGame, 60, 160, 160, 2 * ig.ua.pixelRatio);
ig.system.canvas.style.width = '320px';
ig.system.canvas.style.height = '320px';
ig.$('#body').style.height = '800px';
}
else {
ig.main('#canvas', MyGame, 60, 480, 320, 1);
}
});
I'm not sure if this is helpful or just causes a lot of scrolling for you guys, but I can't find the culprit in the code. I've tried individual removing calls to most all of the required files (player, crate, lang, etc), but it didn't help.