Removed…
You should not do it this way. Use System.nanoTime() between _render() calls and use the difference as multiplicator for your scrolling offset.
Removed…
No you won’t. You’ll just shift the problem. You have to use polling:
- Create 4 boolean fields in your class: left,up,right,down
- Implement a KeyListener with keyPressed() and keyReleased()
- set the corresponding boolean flag to true, if a cursor key is pressed
- set the corresponding boolean flag to false, if a cursor key is released
- in your _render() method set the apropriate scrollspeed for x/y based on the direction flags
- multiply the result with the System.nanoTime()-difference between two _render()-calls
This way you should get a stable scrollspeed regardless of CPU-Speed and rendering load.
Yeah but I am german, so it doesn’t matter, since we are the only country to have an own locale for our english: de_EN ;D (i’ve really seen that as locale setting for english pages in one of our customers CMS!!!)
Removed…