• Post Reply Bookmark Topic Watch Topic
  • New Topic

start at different locations on a map with scrollers  RSS feed

 
Marc Beck
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am creating a game where the player can choose between several different empires. I have a map that is larger than the screen (with scrollers). Right now, the game starts in the upper left corner of the map and the player always has to scroll to his/her base. But I would like to change it, so the game always starts at the base of the empire the player has selected, which can be at any location on the map.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16009
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, can you explain in detail what it is exactly that you are having problems with?

Is the game a Swing application? Is your question: how to set the scroll bars to a certain position programmatically?
 
Marc Beck
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The game is a swing application and setting the scroll bars to a certain position programmatically is exactly what I want to do. Sorry that I did not express myself clearly enough earlier.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16009
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See The Java Tutorial: How to Use Scroll Panes for a good overview of how scroll panes work and how to use them.

You can scroll a scroll pane to a certain position using the method scrollRectToVisible(...).
 
Marc Beck
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot. I will try it out
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!