我在Android上完成了我的第一个libgdx游戏,我一直试图将它移植到iOS上。我已经尝试过MobiDevelop RoboVM和Intel Multi-OS Engine。游戏似乎在模拟器上运行正常,但在设备(iPhone 5)上它绝对无法播放。
Here's an example just on the main menu
按钮是添加到舞台的ImageButtons
_imgPlayButtonUnpressed = new TextureRegion(assetManager.get("img/button_resume_unpressed.png", Texture.class));
_imgPlayButtonPressed = new TextureRegion(assetManager.get("img/button_resume_pressed.png", Texture.class));
_buttonPlay = new ImageButton(new TextureRegionDrawable(_imgPlayButtonUnpressed), new TextureRegionDrawable(_imgPlayButtonPressed));
通过做一些数学运算并在render()
中调用setBounds来激活按钮 if (_animIntervals % 2 == 0) {
width = Animation.easeOutCubic(_animTime, Constants.BUTTON_LARGE_WIDTH, 30, Constants.ANIM_BUTTON_PULSE_INTERVAL);
x = Animation.easeOutCubic(_animTime,(Constants.VIRTUAL_WIDTH - Constants.BUTTON_LARGE_WIDTH) / 2, -15, Constants.ANIM_BUTTON_PULSE_INTERVAL);
y = Animation.easeOutCubic(_animTime, 450, -15, Constants.ANIM_BUTTON_PULSE_INTERVAL);
} else {
width = Animation.easeInOutCubic(_animTime, Constants.BUTTON_LARGE_WIDTH + 30, -30, Constants.ANIM_BUTTON_PULSE_INTERVAL);
x = Animation.easeInOutCubic(_animTime, ((Constants.VIRTUAL_WIDTH - Constants.BUTTON_LARGE_WIDTH) / 2) - 15, 15, Constants.ANIM_BUTTON_PULSE_INTERVAL);
y = Animation.easeInOutCubic(_animTime, 450 - 15, 15, Constants.ANIM_BUTTON_PULSE_INTERVAL);
}
_parent.batch.draw(_imgTransparentOverlay, (Constants.VIRTUAL_WIDTH - Constants.BUTTON_LARGE_WIDTH) / 2, 450, width + 15, width + 15);
_buttonPlay.setBounds(x, y, width, width);
使用SpriteBatch
绘制背景中的正方形private TextureRegion _imgRed;
...
_imgRed = new TextureRegion(assetManager.get("img/normal_red.png", Texture.class));
...
for (int i = 0; i < Constants.BOARD_MENU_SIZE_X; ++i) {
for (int j = 0; j < Constants.BOARD_MENU_SIZE_Y; ++j) {
Square s = _board.getSquare(i, j);
if (s.getType() == Square.Type.Corrupted) {
block = _imgRed;
} else if (s.getType() == Square.Type.Defragmented) {
block = _imgGreen;
} ...
float imgX = SQUARES_INITIAL.x + i * Board.BLOCK_TOTAL_WIDTH;
float imgY = SQUARES_INITIAL.y + j * Board.BLOCK_TOTAL_WIDTH;
_parent.batch.draw(block, imgX, imgY, Board.getBlockWidth(), Board.getBlockWidth());
}
}
关于要注意什么的任何线索或提示?