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 suffrage

Seems pretty simple but I can't seem to get it to work. I just want to create an entity that does not collide with collision tiles. Here was my initial thought:

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

I'm just creating some falling leaves, so if there's a better way to go about it I'm up for that as well.

1 decade ago by quidmonkey

You don't wanna use res at all:
handleMovementTrace: function (res) {
    this.pos.x += this.vel.x * ig.system.tick;
    this.pos.y += this.vel.y * ig.system.tick;
}

1 decade ago by mtg101

I found I needed to update the location as well as make the collision false. Oh and also found I needed to make those changes before calling parent():

        handleMovementTrace: function( res ) {
          //override collisions with background
          res.collision.x = false;
          res.pos.x = this.pos.x + this.vel.x * ig.system.tick;          
          res.collision.y = false;
          res.pos.y = this.pos.y + this.vel.y * ig.system.tick;          
          this.parent( res );
        }

1 decade ago by suffrage

Ah, thanks again quidmonkey! That did the trick. MTG, that didn't work for me for some reason (I think my parent(res) function was overriding the changes).

1 decade ago by mtg101

Sounds like I need to go back and check my code, or at least my understanding of handleMovementTrace() :S
Page 1 of 1
« first « previous next › last »