android游戏引擎libgdx使用教程10:双舞台

鸡啄米  •  扫码分享
java代码
  1. package&com.cnblogs.htynkn.game;&&
  2. &&
  3. import&com.badlogic.gdx.applicationlistener;&&&
  4. import&com.badlogic.gdx.gdx;&&&
  5. import&com.badlogic.gdx.inputprocessor;&&&
  6. import&com.badlogic.gdx.graphics.gl10;&&&
  7. import&com.badlogic.gdx.graphics.texture;&&&
  8. import&com.badlogic.gdx.graphics.g2d.textureregion;&&&
  9. import&com.badlogic.gdx.scenes.scene2d.stage;&&&
  10. import&com.badlogic.gdx.scenes.scene2d.ui.image;&&
  11. &&
  12. public&class&javagame&implements&applicationlistener&{&&
  13. &&
  14. stage&stage1;&&&
  15. stage&stage2;&&&
  16. float&width;&&&
  17. float&height;&&
  18. &&
  19. @override&&&
  20. public&void&create()&{&&&
  21. width&=&gdx.graphics.getwidth();&&&
  22. height&=&gdx.graphics.getheight();&&&
  23. stage1&=&new&stage(width,&height,&true);&&&
  24. stage2&=&new&stage(width,&height,&true,stage1.getspritebatch());&&&
  25. image&image&=&new&image(new&textureregion(new&texture(gdx.files&&&
  26. .internal("img/sky.jpg")),&50,&50,&480,&320));&&&
  27. stage1.addactor(image);&&&
  28. image&image2&=&new&image(new&textureregion(new&texture(gdx.files&&&
  29. .internal("img/baihu.png")),&217,&157));&&&
  30. image2.x=(width-image2.width)/2;&&&
  31. image2.y=(height-image2.height)/2;&&&
  32. stage2.addactor(image2);&&&
  33. }&&
  34. &&
  35. @override&&&
  36. public&void&dispose()&{&&&
  37. //&todo&auto-generated&method&stub&&
  38. &&
  39. }&&
  40. &&
  41. @override&&&
  42. public&void&pause()&{&&&
  43. //&todo&auto-generated&method&stub&&
  44. &&
  45. }&&
  46. &&
  47. @override&&&
  48. public&void&render()&{&&&
  49. gdx.gl.glclear(gl10.gl_color_buffer_bit);&&&
  50. stage1.act(gdx.graphics.getdeltatime());&&&
  51. stage2.act(gdx.graphics.getdeltatime());&&&
  52. stage1.draw();&&&
  53. stage2.draw();&&&
  54. }&&
  55. &&
  56. @override&&&
  57. public&void&resize(int&width,&int&height)&{&&&
  58. //&todo&auto-generated&method&stub&&
  59. &&
  60. }&&
  61. &&
  62. @override&&&
  63. public&void&resume()&{&&&
  64. //&todo&auto-generated&method&stub&&
  65. &&
  66. }&&&
  67. }&&

随意打赏

提交建议
微信扫一扫,分享给好友吧。