1 decade ago by Dashryder56
Hey guys, I have tried every combination of collision detection there is yet the two entities always collide, any thoughts? I need the player to pass through the "tire" The player is box 2d and the tire is not.
ig.module( 'game.entities.player' ) .requires( 'plugins.box2d.entity', 'plugins.box2d.entities.polygon' ) .defines(function() { EntityPlayer = ig.Entity.extend({ size: {x: 160, y:122}, name: 'player', health: 100, //gravity: 10, animSheet: new ig.AnimationSheet('media/new/mater3.png', 160, 122 ), type: ig.Entity.TYPE.A, checkAgainst: ig.Entity.TYPE.NONE, collides: ig.Entity.COLLIDES.PASSIVE, gravityFactor: 3, isFixedRotation: true, maxVel: {x:375}, allowSleep: false, canJump: true, onRamp: false, VELX: 100, init: function(x, y, settings) { this.parent( x, y, settings ); this.addAnim( 'idle', 0.08, [0,1] ); this.addAnim( 'fly', 0.07, [1]) ; this.addAnim( 'jump', 0.07, [2]) ; this.body.m_mass = 450; this.currentVelX = this.VELX; }, update: function() { this.parent(); //this.body.SetXForm(this.body.GetPosition(), 0); var _a = this.body.GetAngle(); $('.debug').text(this.vel.x); if (this.onRamp) { // move left or right if ( ig.input.state('left') ) { // this.vel.x = -200; // this.flip = true; this.body.SetAngle(this.body.GetAngle()-0.05); } else if ( ig.input.state('right') ) { // this.vel.x += 10; // this.flip = false; this.body.SetAngle(this.body.GetAngle()+0.05); } } // else { // this.vel.x += this.currentVelX; // } this.vel.x += this.currentVelX; // if (this.canJump) { // this.currentVelX = this.currentVelX + 1; // } if ( ig.input.pressed('jump') ) { console.log('try jump'); //if (!this.standing) { if (this.pos.y > 259 && this.canJump === true) { this.vel.y = -600; console.log('jump'); } } if (ig.input.pressed('down')) { console.log('down'); this.vel.y = 600; } if (this.pos.y > 259 || this.onRamp) { this.currentAnim = this.anims.idle; } else { this.currentAnim = this.anims.jump; } this.currentAnim.flip.x = this.flip; }, slowDown: function() { this.vel.x = 100; this.currentVelX = 10; this.canJump = false; console.log('slow down'); }, // for tumbleweed (don't disable jump) slowDown2: function() { this.vel.x = 100; this.currentVelX = 10; }, speedUp: function() { this.currentVelX = this.VELX; this.canJump = true; console.log('speed up'); }, rampJump: function() { console.log('ramp jump'); this.onRamp = true; this.isFixedRotation = false; this.currentVelX = 375; }, /* updateTilt: function() { this.currentAnim.angle = 240; }, debugTilt: function(angle) { this.angle = angle; this.currentAnim.angle = angle; //console.log(this.currentAnim.angle); },*/ kill: function() { ig.game.increaseScore(100); ig.game.saveScore(); } }); }); ig.module( 'game.entities.tire' ) .requires( 'impact.entity' ) .defines(function(){ EntityTire = ig.Entity.extend({ size: {x: 75, y: 44}, name: 'tire', gravityFactor: 0, animSheet: new ig.AnimationSheet( 'media/new/tire.png', 75, 44), bounciness: 1, type: ig.Entity.TYPE.NONE, checkAgainst: ig.Entity.TYPE.NONE, collides: ig.Entity.COLLIDES.NEVER, init: function( x, y, settings ) { this.addAnim( 'idle', 1, [0] ); this.parent( x, y, settings ); } }); });