Wednesday, 30 January 2019

30/1/2018 - Colorman dodge (Basic codes)




These are some basic codes samples I think I would use it much in the future:
  • <activity android:screenOrientation = "sensorLandscape"> inside AndroidManifest.xml file to make sure that the gamescreen is in landscape mode.
  • private int screenWidth = Resources.getSystem().getDisplayMetrics().widthPixels; //get the screen height
  • private int screenHeight =Resources.getSystem().getDisplayMetrics().heightPixels; //get the screen height
  • private Bitmap image = BitmapFactory.decodeResource(getResources(),R.mipmap.ic_launcher); //get the image of ic_launcher in res/mipmap

  • In order to make the graphics work on any screen, every images is related to each other. For example, no matter what the screen size is, colorman will always walking on the ground, this is because I make the colorman sprite grow with background. If the background grow at the scale of 2, the colorman sprite will grow at the scale of 2 too.
  • Colorman moving left and right when user touches the left side of the screen, and the right side of the screen. (the upper left corner still have the original hailstone file)

No comments:

Post a Comment

18/7/2019 - Survive that planning

Planning A top-down shooting game Player use WASD to move Use mouse cursor to aim Mouse left-click to shoot, and right click to throw ...