游戏帮助就是告诉用户游戏规则,游戏设计了三幅图片
从左到右分别是三个屏幕的画面,点击右下角的按钮跳到下一屏,最后返回主菜单
三个屏也定义了三个类来实现,分别是HelpScreen,HelpScreen2,HelpScreen3,内部实现几乎一样,只是draw的图片不同而已
看看HelpScreen的代码就可以了
package com.badlogic.androidgames.mrnom; import java.util.List; import com.badlogic.androidgames.framework.Game; import com.badlogic.androidgames.framework.Graphics; import com.badlogic.androidgames.framework.Input.TouchEvent; import com.badlogic.androidgames.framework.Screen; public class HelpScreen extends Screen { public HelpScreen(Game game) { super(game); } @Override public void update(float deltaTime) { List<TouchEvent> touchEvents = game.getInput().getTouchEvents(); game.getInput().getKeyEvents(); int len = touchEvents.size(); for(int i = 0; i < len; i++) { TouchEvent event = touchEvents.get(i); if(event.type == TouchEvent.TOUCH_UP) { if(event.x > 256 && event.y > 416 ) { game.setScreen(new HelpScreen2(game)); if(Settings.soundEnabled) Assets.click.play(1); return; } } } } @Override public void present(float deltaTime) { Graphics g = game.getGraphics(); g.drawPixmap(Assets.background, 0, 0); g.drawPixmap(Assets.help1, 64, 100); g.drawPixmap(Assets.buttons, 256, 416, 0, 64, 64, 64); } @Override public void pause() { } @Override public void resume() { } @Override public void dispose() { } }
game.setScreen(new HelpScreen3(game));