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

2020/4/23

1v1 Soccer Game vs AI

CardJitsu5 CardJitsu5

2020/4/23

#
I am making a soccer game and I'm wondering how I can get my character to hit a ball when they make contact. Also where would the code go? Thank you in advance.
danpost danpost

2020/4/23

#
CardJitsu5 wrote...
I am making a soccer game and I'm wondering how I can get my character to hit a ball when they make contact. Also where would the code go? Thank you in advance.
When building a class, behaviors of objects the class creates are described by methods (and states are represented by field values). In other words, it would be coded (as a method) in the class of the character that hits a ball.
CardJitsu5 CardJitsu5

2020/4/23

#
danpost wrote...
CardJitsu5 wrote...
I am making a soccer game and I'm wondering how I can get my character to hit a ball when they make contact. Also where would the code go? Thank you in advance.
When building a class, behaviors of objects the class creates are described by methods (and states are represented by field values). In other words, it would be coded (as a method) in the class of the character that hits a ball.
Right thanks mate. Is there a specific method I need to use? Or how can I find the appropriate one?
danpost danpost

2020/4/23

#
CardJitsu5 wrote...
Is there a specific method I need to use? Or how can I find the appropriate one?
I do not think you quite understand. You would add and build the method yourself to give the actor that ability. Sure, you would probably call other methods within the method you create (like, in this case, isTouching or getOneIntersectingObject) and you can find all the ones provided for an actor in the Actor class API documentation.
CardJitsu5 CardJitsu5

2020/4/24

#
danpost wrote...
I do not think you quite understand. You would add and build the method yourself to give the actor that ability. Sure, you would probably call other methods within the method you create (like, in this case, isTouching or getOneIntersectingObject) and you can find all the ones provided for an actor in the Actor class API documentation.
Yeah I'm not great at this at all haha. Thanks for your help mate
You need to login to post a reply.