Collided_With argument

12 views
Skip to first unread message

Steve Marcus

unread,
Sep 11, 2013, 2:57:59 PM9/11/13
to alternate-java-bridg...@googlegroups.com
Hi all,

What is the argument passed into Events.COLLIDED_WITH, for "other sprite"?

if (component.equals(imageSprite1) && eventName.equals(Events.COLLIDED_WITH)) {
    doCollision(**what goes here**);
    return true;
    }
.
.
.
private void doCollision(**what goes here**) {
if (**what goes here** == imageSprite2) {
                //do something
}
}


I want to test if for example the other Sprite is imageSprite2, then do something.

Is it something like args[0].toString()? Though I guess it shouldn't be a string, it should be a component name?

Thanks,


S

Imp Inc

unread,
Sep 11, 2013, 7:43:36 PM9/11/13
to alternate-java-bridg...@googlegroups.com
It's a Sprite. You can just cast it to ImageSprite, if you're not using the Ball class at all.

 doCollision((ImageSprite) args[0]);

- Ryan

Steve Marcus

unread,
Sep 12, 2013, 8:24:49 AM9/12/13
to alternate-java-bridg...@googlegroups.com
Perfect, thanks.
Reply all
Reply to author
Forward
0 new messages