【发布时间】:2016-05-20 00:19:27
【问题描述】:
我是编程初学者,我在 Youtube 上找到了有关如何使用 Android Studio 和 LibGDX 编写简单游戏的视频教程。在第 34 部分 ('https://www.youtube.com/watch?v=2R_e9wceHZA') 之前,教程进展顺利。我创建了 FloorEntity 和 SpikeEntity(“在我的项目中它被称为 StingEntity”)当我运行它时,Android Studio 抱怨一系列错误。错误如下:
Error:(62, 24) Gradle: error: ';' expected
Error:(77, 22) Gradle: error: ';' expected
Error:(77, 34) Gradle: error: ';' expected
Error:(87, 23) Gradle: error: ';' expected
Error:(91, 1) Gradle: error: reached end of file while parsing
GameScreen.java 中的代码如下:
package com.mygame;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.World;
import com.badlogic.gdx.utils.viewport.FitViewport;
import com.mygame.desktop.BaseScreen;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.mygame.entities.FloorEntity;
import com.mygame.entities.PlayerEntity;
import com.mygame.entities.StingEntity;
import com.mygame.scene2d.ActorSting;
import java.util.ArrayList;
import java.util.List;
public class GameScreen extends BaseScreen {
private Stage stage;
private World world;
private PlayerEntity player;
private List<FloorEntity> floorList = new ArrayList<FloorEntity>();
private List<StingEntity> stingList = new ArrayList<StingEntity>();
public GameScreen(MainGame game) {
super(game);
stage = new Stage(new FitViewport(640, 480));
world = new World (new Vector2(0,-10), true);
}
@Override
public void show() {
Texture playerTexture = game.getManager().get("blockman.png");
Texture floorTexture = game.getManager().get("floor.png");
Texture overfloorTexture = game.getManager().get("overfloor.png");
Texture stingTexture = game.getManager().get("sting.png");
floorList.add(new FloorEntity(world, floorTexture, overfloorTexture, 0, 1000, 1));
stingList.add(new StingEntity(world, stingTexture, 6, 1));
player = new PlayerEntity(world, playerTexture, new Vector2(1, 2));
stage.addActor(player);
for (FloorEntity floor : floorList) {
stage.addActor(floor);
}
for (StingEntity sting : stingList) {
stage.addActor(sting);
}
@Override
public void hide () {
player.detach();
player.remove();
for (FloorEntity floor : floorList) {
floor.detach();
floor.remove();
}
for (StingEntity sting : stingList) {
stage.addActor(sting);
sting.detach();
sting.remove();
}
}
@Override
public void render(float delta) {
super.render(delta);
Gdx.gl.glClearColor(0.4f, 0.5f, 0.8f, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.act();
world.step(delta, 6, 2);
stage.draw();
}
@Override
public void dispose();{
stage.dispose();
world.dispose();
}
}
有人可以帮我解决这个问题吗?我将不胜感激!
【问题讨论】:
标签: java android android-studio libgdx