Is their a way to make it where no matter what the screen size is my sprites will always start at a certain position. I am trying to get my sprites to start in the lower right corner area of the screen. I am using a 2D SurfaceView.
|
Get the screen size (this StackOverflow answer says how) and you'll have a vector (of the mathematical variety) representing the bottom-right coordinate of the screen. Now you can just place stuff relative to this vector in order to place things relative to the bottom-right of the screen instead of the top-left. I'm assuming that on Android, (0,0) is the top-left corner of the screen. If it isn't, I'll edit this answer to accommodate. In case it isn't clear how that would work, here's an explanationFirst: please make sure you have a basic understanding of vectors (not the list type, but the mathematical object). The vector tag's description links to a succinct tutorial on vectors within the context of games. Read part one at least. A basic understanding of vectors is critical for game programmers, if only because it will make your life easier. Remember that the origin of the screen, which sits at the top left, is So if you want to place something 25 pixels left and 20 pixels up from the bottom-right corner, you're placing it at In code, assuming you have a 2-dimensional vector class named
|
|||||||||
|
