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

2020/1/1

Can you help me?

Alex_White1501 Alex_White1501

2020/1/1

#
How can a fix this error "non-static method bumpCount(int) cannot be referenced from a static context"?
danpost danpost

2020/1/1

#
Alex_White1501 wrote...
How can a fix this error "non-static method bumpCount(int) cannot be referenced from a static context"?
Call bumpCount on an instance of the class - not on the class itself.
Alex_White1501 Alex_White1501

2020/1/1

#
danpost do you mean writing in the World class?
Alex_White1501 Alex_White1501

2020/1/1

#
Wait danpost like this
  

 public void bumpCount(int amount)
   { 
       if (getX()<0);
    }
danpost danpost

2020/1/1

#
Alex_White1501 wrote...
danpost do you mean writing in the World class?
Wait danpost like this << Code Omitted >>
It should be wherever your count variable is. But, for one thing, you cannot use getX on a World object. For another, unless your world is unbound, an actor can never have an x-coordinate value less than zero.
Alex_White1501 Alex_White1501

2020/1/1

#
Thanks for your help danpost I'm trying to make scoreboard system for a pong type game that I'm making for my university assignment.
danpost danpost

2020/1/1

#
Alex_White1501 wrote...
Thanks for your help danpost I'm trying to make scoreboard system for a pong type game that I'm making for my university assignment.
Keep the scores in your World subclass. There is also the alternative of keeping them in your Ball class. However, you must only use one, and the same, ball throughout your game. Also, you would need to keep a reference to that ball in your World subclass if the ball is ever removed from the world during a game (so you can put the same ball back into the world).
Alex_White1501 Alex_White1501

2020/1/1

#
I've got it! thank you very much. What is the best code to make a ball bounce around in a realistic way?
turn(Greenfoot.getRandomNumber(360));
This is what I'm using
danpost danpost

2020/1/2

#
Alex_White1501 wrote...
What is the best code to make a ball bounce around in a realistic way? << Code Omitted >> This is what I'm using
To be "realistic", you would change the angle based on its current rotation (direction) and the angle of the surface on which it bounces.
You need to login to post a reply.