This site requires JavaScript, please enable it in your browser!
Greenfoot back
alinasomcutean
alinasomcutean wrote ...

2017/5/6

Collision detect

alinasomcutean alinasomcutean

2017/5/6

#
I have a personaj class, a finish class and a die class . How can i detect in die class if personaj is collision with finish class?
Super_Hippo Super_Hippo

2017/5/6

#
//in act method of Personaj
if (isTouching(Finish.class))
{
    //do something
}
alinasomcutean alinasomcutean

2017/5/6

#
But can I do it in act method of Die? Because actually there I need to know if these 2 clasees is collising or not
Super_Hippo Super_Hippo

2017/5/6

#
Two classes will never collide. One object of a class can collide with another object. So either you get a reference to the Die object when a collision was detected in the Personaj class or the Die object needs to get a reference to at least one of the other objects.
You need to login to post a reply.