Question: MouseMotionListener and Runnable???
I'm working on several programs , and trying to merge them...
One program implements MouseMotionListener, and updates a game paddle at the bottom of my animation scene.
Another program implements Runnable, and a continuous loop inside RUN() bounces a ball around the screen.
My question is, how come I can't implement MouseMotionListener AND Runnable in the same program, when I try to do it, nothing works!!!
I can provide source if you desire, but an applet that works the way i want it so far can be found on this web site:
The applet that is there implements MouseMotionListener, and the animation only takes place when mouseMoved is called.
What I want is for a separate thread (or all the animation could take place in the same thread, that's ideal...) to animate a ball that bounces around the screen...I can figure the rest out, I'm making a breakout game.
Later and thank you, if you can help me,
MouseMotionListener and Runnable should work perfectly together, you must have set
it up wrong, so you should post the code.
Ok, this was my latest attempt, I put everything in the run() function.
Will the mouseMoved() event, when triggered, interrupt a thread?
The applet doesn't seem to get off the ground, I've attached the source, graphics files, and sampling html file to test run the applet.
PS. Do you have any sample source code of these two interfaces working together, I would appreciate it very much at this point, but I'm still looking to get it to run correctly.
PPS, when I do finally get it, i'll post the source code here too.
That was quite an exotic approach...
I have restructured your applet, there was a lot of things to change, but
instead of me spending time going into every detail I suggest that you
have a good look at what I've done here.
Basically I've divided the applet into methods that enables the correct
sequential processing that an imageLoading & animated applet is supposed to.
Note: a sleep(5) during the animation gives 200 ticks per second, ...how fast
is your screen/eyes ...... You will have to reconsider that.
I haven't tested it though, but I suspect that you have some more tweaking to do here.
Awesome, thank you!!!
Your code worked.
not at first...there was a misspelling imageloader and imageLoader didn't match up...
...and the backg image was created originally to fill the entire screen, so I fixed that using getScaledInstance.
You are awesome, I will update you in this forum as to my progress.
Here is the final updated at this stage...I will still need to study your code so more also. That package thing was cool too, but I commented it out so my usual directory was updated, not the new package one.
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL