Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Page 2 of 2 FirstFirst 12
Results 26 to 29 of 29

Thread: Challenge: I need an animation loop outside of the paint method.

  1. #26
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Challenge: I need an animation loop outside of the paint method.

          myX = Math.random() * 200 - 99;//star starts in a small square
          myY = Math.random() * 200 - 99;//in the center
          myLayer = Math.random() * 3;//random layer
          stars[index] = new Star();//fill array with stars
    Why are you creating new values for the three variables if they are not being passed to the constructor?

  2. #27
    Member
    Join Date
    Aug 2011
    Posts
    86
    My Mood
    Lurking
    Thanks
    16
    Thanked 4 Times in 4 Posts

    Default Re: Challenge: I need an animation loop outside of the paint method.

    they do get in there though. the random numbers get to the constructor because I did not declare them private. I was having a problem using the random in the constructor because my star.class was put together a little unorthodox. Random works in there now.

  3. #28
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Challenge: I need an animation loop outside of the paint method.

    they do get in there though
    How is that? Is it some kind of magic?
    What is the purpose of assigning values to the three variables if they are not being used?

  4. #29
    Member
    Join Date
    Aug 2011
    Posts
    86
    My Mood
    Lurking
    Thanks
    16
    Thanked 4 Times in 4 Posts

    Default Re: Challenge: I need an animation loop outside of the paint method.

    It did work, how ever my code has been polished and the random generators are now in the constructor. Infact new values are no longer created like that, myX, myY, ect only get values set to them during a call to get methods. thank you for all your help, my StarScape is now worthy to be put in my portfolio.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Inheriting Applet and paint() GUI Method Logic?
    By Jakesta42 in forum Object Oriented Programming
    Replies: 1
    Last Post: August 8th, 2011, 06:58 AM
  2. [SOLVED] How do you get this fountain to animate with paint method?
    By javapenguin in forum What's Wrong With My Code?
    Replies: 48
    Last Post: May 31st, 2011, 04:00 PM
  3. Blender file with animation, how to import OBJ(w/ animation) into Java?
    By cr80expert5 in forum Object Oriented Programming
    Replies: 0
    Last Post: May 12th, 2011, 03:11 AM
  4. Paint program adding classes to main method class
    By Maxfmc in forum What's Wrong With My Code?
    Replies: 0
    Last Post: April 15th, 2011, 07:01 PM
  5. Replies: 3
    Last Post: April 18th, 2010, 10:08 AM