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.

Results 1 to 2 of 2

Thread: Need help getting my animation to play before while loop

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Need help getting my animation to play before while loop

    Ok, so here's my problem, I'm currently trying to play an animation for my program then create a .5s gap between it and the next animation that plays: (this is just one of the snipets, but the next few are very similar, just with mbtnTwo.startAnimation();, mp2.start(); etc.)


    if (gamenum2 == 1) {
    	mbtnOne.startAnimation(animAlpha);
    	mp.start();
    	start = System.currentTimeMillis();
    	while (System.currentTimeMillis() < (start + 500)) {
    		;
    	}
    	mbtnOne.clearAnimation();
    }

    It works for the most part, the sound effect from "mp.start();" plays then waits for the the while loop to finish (the .5s pause) before moving on to the next part "mp2.start()", but the animation won't play until it goes through all the numbers. Once all the sounds play (its gone through the whole program) it will start all the animations at the same time.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Need help getting my animation to play before while loop

    Another approach:
    Have the first animation use a Timer that waits the duration before starting the next animation.

    Burning a hole in memory by looping seems a waste.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Cannot get Java to play a sound...
    By JumpingUpAndDown in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 20th, 2011, 09:35 AM
  2. Will Play! Framework Java is he interested in?
    By laresistance2 in forum Web Frameworks
    Replies: 1
    Last Post: September 22nd, 2011, 01:26 PM
  3. Challenge: I need an animation loop outside of the paint method.
    By Spidey1980 in forum Java Theory & Questions
    Replies: 28
    Last Post: August 20th, 2011, 09:20 AM
  4. How to play Audio file?
    By sush in forum Object Oriented Programming
    Replies: 3
    Last Post: June 29th, 2011, 08:11 AM
  5. 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

Tags for this Thread