我试图覆盖我的Player类,它扩展了Actor绘制方法,但我收到一个错误说
The method draw(SpriteBatch, float) of type Player must overrIDe or
implement a supertype method
为什么我不能从类Actor中覆盖默认的draw方法?这是我在Player类中的代码.
public class Player extends Actor { @OverrIDe public voID draw(SpriteBatch batch, float parentAlpha) { Gdx.app.log(getname(), "Drawing player"); } public Player() { setname("mainPlayer"); playerBounds = new Rectangle(100, 100, 32, 32); }}
这是我正在绘制舞台的类中的代码.
public class Mainscreen implements Screen { // Class TAG private static final String TAG = "Main Screen"; // Screen Variable(s) private Awakening g; private SpriteBatch sprBatch; private OrthographicCamera gameCamera; private Player mainPlayer; // Screen Stage(s) private sMain sMain; @OverrIDe public voID dispose() { sprBatch.dispose(); sMain.dispose(); } @OverrIDe public voID hIDe() { g.inputController.removeProcessor(sMain); dispose(); } public Mainscreen(Awakening game){ g = game; sMain = new sMain(g, g.configMgr.getWIDth(), g.configMgr.getHeight(), true); gameCamera = new OrthographicCamera(); gameCamera.setToOrtho(false, sMain.getWIDth(), sMain.getHeight()); mainPlayer = new Player(g, gameCamera); g.setPlayer(mainPlayer); sprBatch = new SpriteBatch(); g.mapMgr.setMap(g, gameCamera, "TestMap", mainPlayer); sMain.addActor(mainPlayer); } @OverrIDe public voID pause() {g.togglePause(true);g.deBUGOut(TAG, "pause()");} @OverrIDe public voID render(float delta) { if(!g.isPaused()){ sMain.act(delta); Gdx.gl.glClearcolor(.125f, .125f, .125f, 0); Gdx.gl.glClear(GL10.GL_color_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); gameCamera.update(); g.mapMgr.updateNPCS(); sprBatch.setProjectionMatrix(gameCamera.combined); sprBatch.begin(); g.mapMgr.draw(gameCamera, new int[] {0,1}); sMain.draw(); // Draw player/NPCs //g.getPlayer().draw(sprBatch, 0f); g.mapMgr.drawCollisionRectangles(gameCamera); sprBatch.end(); } } @OverrIDe public voID resize(int wIDth, int height) {g.deBUGOut(TAG,"resize("+wIDth+","+height+")");} @OverrIDe public voID resume() {g.togglePause(false);g.deBUGOut(TAG, "resume()");} @OverrIDe public voID show() { g.deBUGOut(TAG, "show()"); g.inputController.addProcessor(sMain); g.updateinput(); }}
我不确定发生了什么,但很确定我可以覆盖之前的抽奖.
解决方法:
你必须像这样覆盖它:
@OverrIDepublic voID draw(Batch batch, float parentAlpha) { Gdx.app.log(getname(), "Drawing player");}
将SpriteBatch更改为Batch.参考Actor#draw
总结以上是内存溢出为你收集整理的java – LibGDX Actor绘制覆盖全部内容,希望文章能够帮你解决java – LibGDX Actor绘制覆盖所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)