1 decade ago by jizaymes
Hello,
I'm working on a zone entity that I specify the type for in Weltmeister, and refer to that to determine what action it takes. For example, if you walk over rocks, your health will decrease and your speed will slow down.
My implementation for this calls for an outer zone (reset) which sets the speed back to normal, and inner zones (damage). The notion was that as they walk away from the rocks, it'll reset the speed back to normal.
The problems I'm encountering is that the zone entities check function is triggering for the wrong type. The area that should be setting the speed does nothing, and a console.log reports it as being a damage zone which is just not right.
An image is available here which may paint a better picture.
https://skitch.com/amcops/epcx1/world-map
Any help appreciated. Thanks
I'm working on a zone entity that I specify the type for in Weltmeister, and refer to that to determine what action it takes. For example, if you walk over rocks, your health will decrease and your speed will slow down.
My implementation for this calls for an outer zone (reset) which sets the speed back to normal, and inner zones (damage). The notion was that as they walk away from the rocks, it'll reset the speed back to normal.
The problems I'm encountering is that the zone entities check function is triggering for the wrong type. The area that should be setting the speed does nothing, and a console.log reports it as being a damage zone which is just not right.
An image is available here which may paint a better picture.
https://skitch.com/amcops/epcx1/world-map
ig.module( 'game.entities.zone' ).requires( 'impact.entity' ) .defines(function() { EntityZone = ig.Entity.extend({ _wmDrawBox: true, _wmScalable: true, size: {x: 16, y: 16}, checkAgainst: ig.Entity.TYPE.BOTH, init: function(x, y, settings){ this.parent(x, y, settings); switch(this.type) { case "damage": this._wmBoxColor = 'rgba(0, 0, 255, 0.7)'; this.tim = new ig.Timer( 0.5 ); this.tim.pause(); break; default: this._wmBoxColor ='rgba(255, 0, 255, 0.7)'; break; } }, tim: null, check: function(other) { if( other instanceof EntityPlayer ) { console.log('Colliding with ' + other.name + ' / Zone Type: ' + this.type); switch(this.type) { case "damage": this.tim.unpause(); if( this.tim.delta() > 0.5 ) { other.receiveDamage(this.damageAmount); other.speed = other.defaultSpeed * 0.30; console.log("Slowing down player " + other.speed); this.tim.reset(); } break; default: if (other.speed != other.defaultSpeed) { other.speed = other.defaultSpeed; console.log('Settings speed to: ' + other.speed); } break; } this.parent(); } } }); });
Any help appreciated. Thanks