android游戏引擎libgdx使用教程10:双舞台
java代码
- package&com.cnblogs.htynkn.game;&&
- &&
- import&com.badlogic.gdx.applicationlistener;&&&
- import&com.badlogic.gdx.gdx;&&&
- import&com.badlogic.gdx.inputprocessor;&&&
- import&com.badlogic.gdx.graphics.gl10;&&&
- import&com.badlogic.gdx.graphics.texture;&&&
- import&com.badlogic.gdx.graphics.g2d.textureregion;&&&
- import&com.badlogic.gdx.scenes.scene2d.stage;&&&
- import&com.badlogic.gdx.scenes.scene2d.ui.image;&&
- &&
- public&class&javagame&implements&applicationlistener&{&&
- &&
- stage&stage1;&&&
- stage&stage2;&&&
- float&width;&&&
- float&height;&&
- &&
- @override&&&
- public&void&create()&{&&&
- width&=&gdx.graphics.getwidth();&&&
- height&=&gdx.graphics.getheight();&&&
- stage1&=&new&stage(width,&height,&true);&&&
- stage2&=&new&stage(width,&height,&true,stage1.getspritebatch());&&&
- image&image&=&new&image(new&textureregion(new&texture(gdx.files&&&
- .internal("img/sky.jpg")),&50,&50,&480,&320));&&&
- stage1.addactor(image);&&&
- image&image2&=&new&image(new&textureregion(new&texture(gdx.files&&&
- .internal("img/baihu.png")),&217,&157));&&&
- image2.x=(width-image2.width)/2;&&&
- image2.y=(height-image2.height)/2;&&&
- stage2.addactor(image2);&&&
- }&&
- &&
- @override&&&
- public&void&dispose()&{&&&
- //&todo&auto-generated&method&stub&&
- &&
- }&&
- &&
- @override&&&
- public&void&pause()&{&&&
- //&todo&auto-generated&method&stub&&
- &&
- }&&
- &&
- @override&&&
- public&void&render()&{&&&
- gdx.gl.glclear(gl10.gl_color_buffer_bit);&&&
- stage1.act(gdx.graphics.getdeltatime());&&&
- stage2.act(gdx.graphics.getdeltatime());&&&
- stage1.draw();&&&
- stage2.draw();&&&
- }&&
- &&
- @override&&&
- public&void&resize(int&width,&int&height)&{&&&
- //&todo&auto-generated&method&stub&&
- &&
- }&&
- &&
- @override&&&
- public&void&resume()&{&&&
- //&todo&auto-generated&method&stub&&
- &&
- }&&&
- }&&