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 MikeD

I'm trying to get the Box 2D plugin into a game I had started. At the moment when I try to load the game I get an error in entity.js at line 31, Cannot call method 'CreateBody' of undefined.

My main.js starts:

ig.module( 
	'game.main' 
)
.requires(
	'impact.game',
	'game.levels.tutorial3',
	'game.entities.bunny',
	'game.entities.spikes',
	'plugins.box2d.game'
)
.defines(function(){

MyGame = ig.Box2DGame.extend({
	gravity: 100,
	

I have two entities, the first starts:

ig.module(
	'game.entities.bunny'
)
.requires(
	'impact.entity',
	'plugins.box2d.entity'
)
.defines(function(){

EntityBunny = ig.Box2DEntity.extend({
    animSheet: new ig.AnimationSheet( 'media/BunnySprite.png', 50, 50 ),
    size: {x: 50, y:50},
flip: false,
    idleTimer: null,
    idle: true,
    idleDelay: 3,
    startPosition: null,
    type: ig.Entity.TYPE.A,
    checkAgainst: ig.Entity.TYPE.NONE,
    collides: ig.Entity.COLLIDES.NEVER,

and the other:

ig.module(
	'game.entities.spikes'
)
.requires(
	'plugins.box2d.entity'
)
.defines(function(){

	EntitySpikes = ig.Box2DEntity.extend({
		animSheet: new ig.AnimationSheet( 'media/spikes.png', 50, 50 ),
	    size: {x: 50, y:50},
	    type: ig.Entity.TYPE.B,
    	checkAgainst: ig.Entity.TYPE.A,
    	collides: ig.Entity.COLLIDES.NEVER,	
    	

I created a new level which has a row of tiles at the bottom and one each of the two entities.

I'm doing something wrong, but I can't see it for looking.

Any ideas?

1 decade ago by StuartTresadern

Do you get the same error if only one of your entities gets loaded ? Also do you need the requires for 'impact.entity', in your bunny entity.

1 decade ago by MikeD

I've tried taking out both entities one at a time, but that makes no difference. Even with both entities out I get the same error.

I think it is happening when the level is loaded in init in main.js. If I comment out the level load it gets further and gives me a different error in the update function.

Is there something different I have to do in Weltmeister, or the level's js file?

1 decade ago by StuartTresadern

No you setup the levels in Weltmeister in the normal way and you do not need to edit the level files. If you have a cut down version you can zip up and email I can take a look.

1 decade ago by MikeD

Ah I found it. I have to have a collision layer in the level. I was planning on using a Box2D shape for the ground so had no real need for a collision layer...

1 decade ago by StuartTresadern

Great good look with the game.
If you look in the game.js file in the box2d plugins folder you will see that the collision layer is used to create the box2d ground layer from the tiles. Basically you can remove all this code so that the collision layer is not required. You will also need to make a few changes to collison.js in the same folder so that its not looking for the collison map.
Page 1 of 1
« first « previous next › last »