Skip to content

Instantly share code, notes, and snippets.

@demonixis
Created August 6, 2012 20:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save demonixis/3278010 to your computer and use it in GitHub Desktop.
Save demonixis/3278010 to your computer and use it in GitHub Desktop.
Code for adapt scale with a reference resolution
/* Le rectangle jouable a une résolution réel de 1000x760
* La texture d'origine fait 1280x800
* 1 et 2 : Il y a un décallage de 20px entre le debut de la texture (x ,y)
* et la surface de jeu
* 1280 / 64 = 20 --> adaptation à chaque résulutions
* 3 et 4 : 1280 / (1280 / 1000) = 1280 / 1.28 = 1000 soit la largeur max de la surface jouable
* pour avoir la surface jouable relative complète il faut ajouter les 20px de décalage calculé au début
* prenant en compte l'échelle
*/
this.playableSurface = new Rectangle (
screenWidth / 64,
screenHeight / 40,
(int)(screenWidth / (1280.0f / 1000.0f)),
(int)(screenHeight / (800.0f / 760.0f)));
// Dertermination des coefficient de proportionnalité de l'échelle
// Echelle d'origine 1280x800
this.spriteScale = new Vector2 (
(float)screenWidth / 1280.0f,
(float)screenHeight / 800.0f);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment