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 carlos_moreira

I have a moving entity on a map. (Spikes in the ground).

Is there a way to have an entity move through a collision level?

Example I have Spikes on a floor, on a collision level, when the spikes are up, anything in its path is killed. When its down, the player can freely walk above it.

In Weltmeister, I put the spikes inside a collision level, to do that exactly.

Problem : I have this entity moving up and down. When the entity moves up for the first time, it moves above the collision block and gives itself a new (Y-axis) into which it moves up and down.

I've tried playing with the collides , but that only seems to work with other entities.

1 decade ago by Joncom

By default, all entities collide with the collisionMap. You can override this behavior by adding a custom method to your spike entity.

EntitySpike = ig.Entity.extend({

    size: { x: 16, y: 16 },
    /* your entity properties */

    init: function(x, y, settings) {
        this.parent(x, y, settings);
        /* your init code */
    }

    handleMovementTrace: function(res) {
        return; // Do nothing. Do not collide with collisionMap.
    }

});

Hope that helps.

1 decade ago by carlos_moreira

hmm.. I have the code that that move the entity inside the update method.

If i overide the handlemovementtrace method, then nothing happens.

Should I move the code that moves the entity to the handlemovement trace? I think i'm a bit confused with the update and handlemovement methods.
Page 1 of 1
« first « previous next › last »