ZRT Posted February 17, 2014 Share Posted February 17, 2014 Hey guys, I have a weird collision in my 1.1.5 game, sprite VS sprite. I've read on this forum about similar stuff, but not sure it's the same issue that was in 1.1.3 and fixed in 1.1.4. Tried it with 1.1.3, works the same. I made a quick ugly sketch to demonstrate the behavior. The collision works from left and right and top/bottom of the rectangle. But when it "cuts " the edge of it, it just goes through. Here's the code: if (this.game.physics.collide (this.player, this.obBot)) { this.player.kill(); game.state.start('Over'); } if (this.game.physics.collide (this.player, this.obTop)){ this.player.kill(); game.state.start('Over'); }Thanks. EDIT: Another issue is that the collision sometimes happens few pixels BEFORE it touch the sprite. Teemu-Tor 1 Link to comment Share on other sites More sharing options...
ZRT Posted February 18, 2014 Author Share Posted February 18, 2014 Anyone? Link to comment Share on other sites More sharing options...
grimor Posted February 18, 2014 Share Posted February 18, 2014 You tried to draw debug info about collision box ? You using circle and rectangle collision boxes ? Link to comment Share on other sites More sharing options...
xdiepx Posted February 18, 2014 Share Posted February 18, 2014 I get that too and sometimes the player gets killed but the object starts moving in the direction i bumped into it. Link to comment Share on other sites More sharing options...
ZRT Posted February 18, 2014 Author Share Posted February 18, 2014 I just found what the problem was. this.player = game.add.sprite(70, 100, 'player'); this.player.body.setCircle(20); this.player.body.gravity.y = 600; this.player.body.bounce = 0.5; this.player.body.collideWorldBounds = true; this.rotation = this.game.add.tween(this.player).to({angle: this.player.angle + 120}); this.rotation.start();The last two lines that add rotation. The player sprite is actually a ball that enters the scene rotating and stops when the movement input is triggered. I removed those two lines and the collision works as intended. Is there any neat way that I can make the sprite rotate without causing the problem in first post? Thanks. EDIT: I don't think I even need tween here. Link to comment Share on other sites More sharing options...
grimor Posted February 18, 2014 Share Posted February 18, 2014 I made a quick demo and works fine, but dunno that cover your problem. http://jsfiddle.net/BSec6/3/ ZRT 1 Link to comment Share on other sites More sharing options...
ZRT Posted February 18, 2014 Author Share Posted February 18, 2014 Thanks. The demo works fine, but still the sprite ball doesn't rotate when it first drops. Anyway, it's a nice guideline and I'll try playing around it and see what happens. Link to comment Share on other sites More sharing options...
grimor Posted February 18, 2014 Share Posted February 18, 2014 Doesn't rotate in your game or in my demo ? I updated it with sprite image, now you can see clearly it's rotating. http://jsfiddle.net/BSec6/4/ Link to comment Share on other sites More sharing options...
ZRT Posted February 18, 2014 Author Share Posted February 18, 2014 Yeah, doesn't rotate in my game. Works fine in your demo. Still trying to make it work. The problem is whenever I add an angle, it rotates weirdly. I moves the sprite position and that's why the collision happens even before both images collide. I must be doing something wrong and stupid and I will post as soon as I fix it. Thanks again. Link to comment Share on other sites More sharing options...
AlexArroyoDuque Posted February 20, 2014 Share Posted February 20, 2014 I have a similar problem. In my case the collision function is not executed when colliding with a "flat" area of tiles Link to comment Share on other sites More sharing options...
Teemu-Tor Posted February 23, 2014 Share Posted February 23, 2014 I also have a similar problem.... collision with rectangle works ok, with cirle not so much. Link to comment Share on other sites More sharing options...
Recommended Posts