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 ansimuz

Hi

I want to detect when an entity touches the collision map on the oneway tiles (the one with the arrows on weltmeister). I am using the handleMovementTrace and it only works on the solid tiles.

Its there a workaround or a im missing something?

handleMovementTrace: function(res){
            this.parent(res);
            if(res.collision.x || res.collision.y){
               this.kill();
            }
        }

1 decade ago by ansimuz

Found the solution myself!

Just needed to add a conditional checking the slope property "ny" like this

res.collision.slope.ny == -1

handleMovementTrace: function(res){
            this.parent(res);
            console.log(res.collision.slope.ny );

            if(res.collision.x || res.collision.y || res.collision.slope.ny == -1 ){
               this.kill();
            }
        }

1 decade ago by jessefreeman

Thanks, this helped me with a similar problem. I was looking for a way to keep enemies in a level by using one way tiles on the edges to allow them to walk in from off screen. Basically I set up spawn points on the outside of the map. I use one way tiles on the right and left of the screen so the spawned enemies walk through those and come into view. I have the following logic which tells if they enemy hits the other side of the one way tiles on the end of the map and turns around or gets killed:

 handleMovementTrace: function (res) {
                this.parent(res);

                // Handles collision with solid and one way tiles
                if (res.collision.x || res.collision.slope.ny == 0) {
                   
                    if (this.flipOnOutOfBounds)
                        this.flip = !this.flip;
                    else
                        this.kill();
                }
  
                if (this.currentAnim)
                    this.currentAnim.flip.x = this.flip;
            }

so far it works perfectly but I still need to check the edge cases.
Page 1 of 1
« first « previous next › last »