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

2019/11/14

Looking for help if possible please...

Jamyjambo Jamyjambo

2019/11/14

#
Hi there I am creating a random drop and catch game about rubbish for an assignment and have so far coded the actors movement and the trash to randomly appear then drop. I have also coded the trash so when it hits the ground it changes image to a splat but here is where I am struggling I know kind of what is required but not how to put it in code I am trying to make it so if the actor walks through the splat image it slows the actor down, so would be getOneIntersectingObject with Trash.class but I only want it too slow actor down if splat image is showing. Thanks in advance for any help. J
danpost danpost

2019/11/15

#
Use separate actors for Trash and Splat.
Jamyjambo Jamyjambo

2019/11/15

#
Thanks for response, how would I make the trash change to the splat then could that still be done as different actors?
Jamyjambo Jamyjambo

2019/11/15

#
Would I just be using getWorld to remove one then add the other?
danpost danpost

2019/11/15

#
Jamyjambo wrote...
Would I just be using getWorld to remove one then add the other?
Yes -- but it would be wise to add the Splat object first or the Trash object will lose any reference to the world it was in.
Jamyjambo Jamyjambo

2019/11/20

#
Thank for the help danpost that has worked perfectly can I ask when using the AtOffset method if 0,0 is the centre point of the actor how would I make it the top edge of my trashman actor so if he hits the trash actor when above him the trash caught bit if it hits his side he misses? Thanks again for you help.
danpost danpost

2019/11/20

#
Actor trash = getOneObjectAtOffset(0, -getImage().getHeight()/2, Trash.class);
would check top center of the collector. You may want to also check the height of the trash above ground -- make sure it is within a specific range (minimum range would be fall speed of trash) before collecting it (before the catch is executed).
You need to login to post a reply.