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

10 years ago by foyleman

New to impactjs but not programming.

I'm having trouble understanding the 2D array in collision maps for impact.

I couldn't find details on how the array is setup.

Can someone point me in the right direction or explain it?

example of my player entity:
size: {x: 64, y: 64},

init: function( x, y, settings ) {
	this.parent( x, y, settings );
	var data = [
		[0,0,0,0],
		[0,1,1,0],
		[0,0,0,0]
	];
	this.collisionMap = new ig.CollisionMap (8, data);
}

In the above example, my entire entity still has total collision. I expect a portion of the entity collide.

How is this array representative of the entity?
Am I missing a directive to activate this new collision model?

10 years ago by Joncom

The collision map belongs to a level, not an entity. Have you made a level using the Weltmeister editor? When you make a collision layer with the editor, that is then converted into a collision map when you load the level in your game.

10 years ago by foyleman

I have made a level and a collision map for the level.

My issue is that I would like to make a more details entity collider. Otherwise it looks like my rounded player avatar is stopping before the wall.

Can I control the entity collision?

10 years ago by Joncom

Your entity collision-shape is a rectangle. This is why your "rounded entity" might appear to stop before the wall. I can think of two solutions. I'll start with the easier one.

1) Make your entity (collision) size smaller than the entity graphic, and use .offset to center the graphic over the collision box. This will let the entity get up nice and close to walls. It might even overlap them a bit, so play with it.

2) Use Box2D. It replaces the default ImpactJS physics engine and supports all different kinds of shaped entities, including rounded ones.
Page 1 of 1
« first « previous next › last »