I am confused as to this point. I just spent 4 hours last night trying to put the animation loop of my StarScape outside of the paint method so that my code does not cripple the system, and have hit a wall.
I have tried to make a method called drawStar(Graphics g). when I call it like I call my other methods, i.e. stars[index].drawStar() It tells me that "drawStars(java.awt.Graphics) cannot be applied to ()"
Could somebody give me and example code of how to accomplish this?
To be helpful to me, here are some guide lines:
1) Create a class Ball.java and an applet Dribble.java
2) in the ball class describe methods for these behaviors:
a) moveBall < this should change the x,y location data at least, for example, one pixel to the right. Does not matter, location data just needs to change.
b) drawBall < this should include a paint method (if possible) and place a drawOval on the screen
c) eraseBall < just what it says.
3) since I'm using an array of objects in my project, the Dribble Applet should create at least 2 ball objects, but instead of ball1, ball2, use ball[num] where num is described in a for loop. This way the call to method would be ball[num].moveBall(). this already works well in my starscape to move the stars when I use: stars[index].moveStar().
4) sucsessfully call the moveBall, drawBall and eraseBall, inside a do...while loop so that the balls keep moving. Again, this should be done outside a paint method, which is where I run into problems.
Refer to It works!!! eureka!!! Java...Day 12.. In that code, I call the moveStar method and some get methods to get the location data, this is done inside a do...while loop within my paint method which is a big no-no. I've tried to satisfy the above guidelines 1-4 in my starscape with no luck.
Thank you for all your help.