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 4 of 4

Thread: Slot machine, animating the reels to spin

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Slot machine, animating the reels to spin

    Hi, I really need help as to how to go about animating the reels on a slot machine.

    Currently i store the images in a panel and when clicking on the spin button it will go through the images and stop after the counter as reached 19. However it just shows each fruit as it's going through the images and i'd like a spinning animation instead like a real slot machine and wondered how i would go about doing this?

    Thank you for reading!


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,434
    Thanks
    49
    Thanked 2,216 Times in 2,189 Posts

    Default Re: Slot machine, animating the reels to spin

    How do you want the animation look?
    Have you tried drawing the image at different y positions over time to make it move in a vertical direction? You will need to do some algebra to compute the postion and to truncate the top of one image as it moves out of view and the next image comes into view.

  3. #3
    Junior Member
    Join Date
    Nov 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Slot machine, animating the reels to spin

    Hi Norm, I'd like it to probably move vertically like you said, is this possible to do?
    I have my images as labels stored in a panel and i've used random.next int to randomly generate through them at the moment.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,434
    Thanks
    49
    Thanked 2,216 Times in 2,189 Posts

    Default Re: Slot machine, animating the reels to spin

    By move I mean that you draw parts of the image starting at the top of the image and move down each time you draw it. Say first drawing shows first row of pixels to the end. Next drawing shows 5th row of pixels to the end, continuing down the rows until none left. The image would appear to move up.

Similar Threads

  1. JMS same machine JBoss
    By IDH123123 in forum Web Frameworks
    Replies: 0
    Last Post: June 21st, 2011, 04:30 AM
  2. Slot Machine
    By nemoisback66 in forum What's Wrong With My Code?
    Replies: 8
    Last Post: November 17th, 2010, 12:57 PM
  3. Moving MySql Database from one machine to another machine
    By vaishali in forum JDBC & Databases
    Replies: 5
    Last Post: July 21st, 2010, 01:21 AM
  4. Replies: 8
    Last Post: February 24th, 2009, 03:04 PM
  5. Replies: 6
    Last Post: November 14th, 2008, 02:09 PM