So far i heave created the following code which create a kind of spinning wheel. At the moment the images jump down 50 pixels at a time which looks jerkey not smooth. Im looking for either some help here or links to other sites where I can find tutorials on this. The main goal is to create a fruit machine style spinning effect.
Any advice would be welcomed feel like I have hit a brick wall..
p.s Any one know any good books specifically for graphical programming
Your animation code runs okay in my j2se 1.5 plug-in. The mouseDown method is deprecated. It was used in the older AWT 1.0 event model which was replaced by a newer event model using event listeners in AWT 1.1. You can find out more about the newer way here: Lesson: Writing Event Listeners. The only animation example I know of at sun is the "TumbleItem.java" example at the top of the page: How to Make Applets. For further suggestions I would need to hear more about the "fruit machine style spinning effect".
thanks for your reply. Yeh the animation is ok, Id just want it to be more smooth, and i cant figure out how to do that...
A good example is.
The desired affect for this part is to make a smooth animation for one reel. For instance in the above example i would only want the third reel moving and moving slowly enough that a user could hit a button and stop the correct image in the middle. E.g to line up three cherrys for a win.
Its this smooth affect im having trouble making.
Thanks in advance again
Alan [ April 24, 2006: Message edited by: Al Hollis ]
deltaX is set to -1 why? It moves the image strip from right to left. If you change the sign of "dx" you can move the image from left to right. What is clip.x??? "clip" is a Rectangle instance variable. Its location (x, y) is set in paintComponent to position it at the center of the panel. To see what its affect is in the animation comment out the line "g2.setClip(clip);". If this new position + the width of the image is less than clip.x??? If the end of the image has moved far enough to the left to no longer be visible inside the "clip" Rectangle, reset the value of "x" to start another pass from right to left. make graphics2D g2 = to ??? what does this mean It casts the graphics context "g" from type Graphics to type Graphics2D. Graphics2D has more/fancier capabilities. Compare the api of the Graphics and Graphics2D classes to see the difference. To learn more about this see the 2D Graphics online tutorial trail. set a new int called dx??? Which is given the value int dx = pos < 0 ? pos + imageWidth : pos - imageWidth; ??? What does this mean??? The easiest way to see what this does is to comment out the entire (enclosing if statement) block and see what is different in the animation. It is a way to make the animation appear to be continuous. What does dispose do??? Releases the system resources that were being used for the graphics context that was created for the BufferedImage.
Ok i have been a busy person... Ive got a few more things i cant work out how to do.. Firstly i have swapped the image from being of horizontal nature to verticle. I have relised though the the area around the clip is much bigger than the clipping region. For the life of me I cannot see where i can change this so i dont have a unsightly grey box around my clipped area.
Ill leave second question for now. Thanks in advance for your help ranchers.
Ok so question two, You know you showed me the code to make the image stop centered.
Well what i tried to do, was instead of it moving backwards to get to the nearest edge make it loop around once more ( So reel is always moving one direction. ). But experimenting with the values there must be something im missing as I cant get it to work. Although the steps worked correctly. The animation stopped playing.. [ May 11, 2006: Message edited by: Al Hollis ]
Fella your a genius. I have now got the reels working exactly how i wanted them to and can call any image i want to "spin in". Thanks again for your time. Hopefully wont be too many more questions now [ May 12, 2006: Message edited by: Al Hollis ]