collision events not firing / no collisions

94 views
Skip to first unread message

dgpark...@gmail.com

unread,
Apr 1, 2018, 10:29:15 AM4/1/18
to excaliburjs
Hey guys,

I'm trying to simply recreate the breakout demo on my own using typescript and for some reason I can't get any of the collisions to work.

I've just got the ball and the paddle right now and no matter what I try I can't seem to get it to bounce off the paddle.

All the event handlers seem to be registering properly (confirmed by inspecting the eventDispatcher object) also the lose condition and the side bounces behave as expected.

I've pretty much read through the entire "I just want groceries" code and have tried to replicate how you guys are doing it in there at one point but it had no effect.

Any help in getting this resolved is greatly appreciated, this is really starting to bum me out :(


Thanks,
Dylan

Kamran Ayub

unread,
Apr 1, 2018, 12:27:38 PM4/1/18
to dgpark...@gmail.com, excaliburjs
Have you enabled active collisions? By default collisions are passive. Passive throws events but doesn't react.

--
You received this message because you are subscribed to the Google Groups "excaliburjs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to excaliburjs...@googlegroups.com.
To post to this group, send email to excal...@googlegroups.com.
Visit this group at https://groups.google.com/group/excaliburjs.
To view this discussion on the web visit https://groups.google.com/d/msgid/excaliburjs/61564cc2-11e0-49ff-b286-fec82cbf1c31%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Message has been deleted

dgpark...@gmail.com

unread,
Apr 1, 2018, 3:22:22 PM4/1/18
to excaliburjs
Not sure what happened to my last response it's saying it got deleted for some reason.

But yes I have tried setting the collision types to active but it doesn't appear to change the behavior.

Erik Onarheim

unread,
Apr 2, 2018, 8:58:14 AM4/2/18
to excaliburjs
Hi Dylan,

I took a look at this last night and I think I have a work-around for you. There is definitely a bug in excalibur here I've opened 2 issues:

The main issue is that excalibur calculates the default geometry for the box collision area in the ex.Actor super constructor, unfortunately it does not get automatically recalculated when the dimensions change.  

The workaround is to supply those (x, y, width, height) to the super constructor

class Paddle extends ex.Actor {
   
public game: ex.Engine;
   constructor
(game: ex.Engine) {
     
super({
        x
: game.drawWidth / 2,
        y
: game.drawHeight - 40,
        width
: 200,
        height
: 20
     
});
   
//   this.game = game;
   
//   this.setWidth(200);
   
//   this.setHeight(20);
   
//   this.x = this.game.drawWidth / 2;
   
//   this.y = this.game.drawHeight - 40;
     
this.color = ex.Color.Chartreuse;
 
     
this.collisionType = ex.CollisionType.Fixed;
 
     
this.addInputListener();
   
}
 
..
}


The second issue I noticed was that the ball left the screen and didn't fire the offscreen exitviewport event at the right time (this happens on my laptop because I have a hidpi screen and the offscreen logic is incorrectly accounting for hidpi devices that multiply canvas resolution). 

The workaround for this is instead of using the 'exitviewport' event use the post updated to check the cooridinates

this.on('postupdate', (e) => {
 
if(this.pos.x < 0 || this.pos.y < 0 || this.pos.x > this.game.drawWidth || this.pos.y > this.game.drawHeight) {
     alert
('You lose!');
 
}
});

Hope this helps.

These 2 bugs are relatively easy to fix, I'll try to get them into the v0.16.0 release that's going out sometime this week.

Let me know if there are more issues,
Erik
Message has been deleted

Erik Onarheim

unread,
Apr 3, 2018, 8:09:29 AM4/3/18
to dgpark...@gmail.com, excaliburjs
Google groups is marking some messages as spam for some odd reason, must be why some were deleted. Feel free to ping me on other channels too if this continues, I've found a way to whitelist authors so fingers crossed.

On Tue, Apr 3, 2018 at 7:06 AM <dgpark...@gmail.com> wrote:
Yes, I've tried setting both the paddle and the ball to active but that doesn't appear to change any of the behavior or raise any collision events. 

Currently it's setup the same way as the breakout getting started project where the paddle is collisiontype fixed and the ball is passive but you handle the collision by registering an event handler on the precollision event.
--
You received this message because you are subscribed to the Google Groups "excaliburjs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to excaliburjs...@googlegroups.com.
To post to this group, send email to excal...@googlegroups.com.
Visit this group at https://groups.google.com/group/excaliburjs.

Erik Onarheim

unread,
Apr 6, 2018, 9:55:40 AM4/6/18
to dgpark...@gmail.com, excaliburjs
We released v0.16.0 last night, geometry recalculation didn't make the cut in time. I'll be our first priority in v0.17.0

dgpark...@gmail.com

unread,
Apr 7, 2018, 3:00:20 PM4/7/18
to excaliburjs
Awesome i'll upgrade tonight then. No worries, the work around right now isn't all that bad. Once I'm finished I'll post the working version up on github and pages so you'll have a decent typescript beginner tutorial that's up to date.
Reply all
Reply to author
Forward
0 new messages