使用Android Studio与AndEnginetMttileExtension一起使用TMXLOADER错误



我正在尝试创建像游戏这样的塔防御。我创建了一个带有瓷砖地图编辑器的瓷砖等距地图,并保存了Android Studio中的资产文件夹。我目前正在使用和引擎来加载地图。

我的MainActivity.java:

package com.example.neelpatel104.towerfinisher;

import org.andengine.engine.Engine;
import org.andengine.engine.LimitedFPSEngine;
import org.andengine.engine.camera.BoundCamera;
import org.andengine.engine.options.EngineOptions;
import org.andengine.engine.options.ScreenOrientation;
import org.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
import org.andengine.entity.scene.Scene;
import org.andengine.entity.util.FPSLogger;
import org.andengine.extension.tmx.TMXLayer;
import org.andengine.extension.tmx.TMXLoader;
import org.andengine.extension.tmx.TMXProperties;
import org.andengine.extension.tmx.TMXTile;
import org.andengine.extension.tmx.TMXTileProperty;
import org.andengine.extension.tmx.TMXTiledMap;
import org.andengine.extension.tmx.util.exception.TMXException;
import org.andengine.extension.tmx.util.exception.TMXLoadException;
import org.andengine.opengl.texture.TextureOptions;
import org.andengine.ui.activity.SimpleBaseGameActivity;
import org.andengine.util.debug.Debug;
public class MainActivity extends SimpleBaseGameActivity  {
private TMXTiledMap mTMXTiledMap;
    private TMXLayer tmxLayer;
    private static final int CAMERA_WIDTH=550;
    private static final int CAMERA_HEIGHT=300;
    private BoundCamera mBoundChaseCamera;
    protected int mCactusCount;
@Override
public Engine onCreateEngine(EngineOptions engineOptions){
    return new LimitedFPSEngine(engineOptions,60);
}
    @Override
    public EngineOptions onCreateEngineOptions(){
        this.mBoundChaseCamera = new BoundCamera(0,0,CAMERA_WIDTH,CAMERA_HEIGHT);return new EngineOptions(true,ScreenOrientation.LANDSCAPE_FIXED,new RatioResolutionPolicy(CAMERA_WIDTH,CAMERA_HEIGHT),this.mBoundChaseCamera);
}
    @Override
    protected void onCreateResources() {
    final TMXLoader tmxLoader = new TMXLoader(getAssets(),getTextureManager(),TextureOptions.NEAREST,mEngine.getVertexBufferObjectManager());
    try {
       this.mTMXTiledMap = tmxLoader.loadFromAsset("map/levelone.tmx");
   } catch (final TMXLoadException e){
            Debug.e(e);
        }
    }
    @Override
    protected Scene onCreateScene() {
       this.mEngine.registerUpdateHandler(new FPSLogger());
        final Scene scene = new Scene();
        this.tmxLayer = this.mTMXTiledMap.getTMXLayers().get(0);
        scene.setChildrenVisible(false);
        scene.setBackgroundEnabled(false);
        scene.attachChild(this.tmxLayer);
        return scene;
    }
}

下面的行给我一个错误:

 final TMXLoader tmxLoader = new TMXLoader(getAssets(),getTextureManager(),TextureOptions.NEAREST,mEngine.getVertexBufferObjectManager());

这是我的完整堆栈跟踪:

Information:Gradle tasks [:app:clean, :app:generateDebugSources,
:app:generateDebugAndroidTestSources, :app:mockableAndroidJar,
:app:prepareDebugUnitTestDependencies, :app:assembleDebug]
/home/neelpatel104/AndroidStudioProjects/TowerFinisher/AndEngine/src/main/java/org/andengine/util/math/MathUtils.java
Error:(89, 50) error: cannot find symbol method ceil(float)
Error:(163, 42) error: cannot find symbol method sin(float)
Error:(164, 44) error: cannot find symbol method cos(float)
Error:(239, 19) error: cannot find symbol method sqrt(float)
Error:(246, 19) error: cannot find symbol method sqrt(float)
/home/neelpatel104/AndroidStudioProjects/TowerFinisher/AndEngine/src/main/java/org/andengine/util/modifier/ease/EaseElasticOut.java
Error:(69, 67) error: cannot find symbol method sin(float)
/home/neelpatel104/AndroidStudioProjects/TowerFinisher/AndEngine/src/main/java/org/andengine/util/modifier/ease/EaseElasticIn.java
Error:(70, 49) error: cannot find symbol method sin(float)
/home/neelpatel104/AndroidStudioProjects/TowerFinisher/AndEngine/src/main/java/org/andengine/util/modifier/ease/EaseSineInOut.java
Error:(52, 28) error: cannot find symbol method cos(float)
/home/neelpatel104/AndroidStudioProjects/TowerFinisher/AndEngine/src/main/java/org/andengine/util/modifier/ease/EaseCircularOut.java
Error:(58, 19) error: cannot find symbol method sqrt(float)
/home/neelpatel104/AndroidStudioProjects/TowerFinisher/AndEngine/src/main/java/org/andengine/util/modifier/ease/EaseCircularIn.java
Error:(57, 21) error: cannot find symbol method sqrt(float)
/home/neelpatel104/AndroidStudioProjects/TowerFinisher/AndEngine/src/main/java/org/andengine/util/modifier/ease/EaseSineOut.java
Error:(59, 19) error: cannot find symbol method sin(float)
/home/neelpatel104/AndroidStudioProjects/TowerFinisher/AndEngine/src/main/java/org/andengine/util/modifier/ease/EaseSineIn.java
Error:(59, 20) error: cannot find symbol method cos(float)
/home/neelpatel104/AndroidStudioProjects/TowerFinisher/AndEngine/src/main/java/org/andengine/util/adt/transformation/Transformation.java
Error:(122, 30) error: cannot find symbol method sin(float)
Error:(123, 30) error: cannot find symbol method cos(float)
Error:(139, 30) error: cannot find symbol method sin(float)
Error:(140, 30) error: cannot find symbol method cos(float)
Error:(160, 30) error: cannot find symbol method sin(float)
Error:(161, 30) error: cannot find symbol method cos(float)
/home/neelpatel104/AndroidStudioProjects/TowerFinisher/AndEngine/src/main/java/org/andengine/util/levelstats/LevelStatsDBConnector.java
Error:(12, 23) error: package org.apache.http does not exist
Error:(13, 23) error: package org.apache.http does not exist
Error:(14, 23) error: package org.apache.http does not exist
Error:(15, 30) error: package org.apache.http.client does not exist
Error:(16, 37) error: package org.apache.http.client.entity does not exist
Error:(17, 38) error: package org.apache.http.client.methods does not exist
Error:(18, 35) error: package org.apache.http.impl.client does not exist
Error:(19, 31) error: package org.apache.http.message does not exist
Error:(82, 12) error: cannot find symbol class HttpClient
Error:(82, 40) error: cannot find symbol class DefaultHttpClient
Error:(83, 12) error: cannot find symbol class HttpPost
Error:(83, 36) error: cannot find symbol class HttpPost
Error:(86, 17) error: cannot find symbol class NameValuePair
Error:(86, 63) error: cannot find symbol class NameValuePair
Error:(88, 29) error: cannot find symbol class BasicNameValuePair
Error:(89, 29) error: cannot find symbol class BasicNameValuePair
Error:(90, 29) error: cannot find symbol class BasicNameValuePair
Error:(91, 29) error: cannot find symbol class BasicNameValuePair
Error:(92, 29) error: cannot find symbol class BasicNameValuePair
Error:(94, 29) error: cannot find symbol class UrlEncodedFormEntity
Error:(97, 12) error: cannot find symbol class HttpResponse
Error:(100, 23) error: cannot find symbol variable HttpStatus
/home/neelpatel104/AndroidStudioProjects/TowerFinisher/AndEngine/src/main/java/org/andengine/util/algorithm/path/astar/EuclideanHeuristic.java
Error:(40, 19) error: cannot find symbol method sqrt(float)
/home/neelpatel104/AndroidStudioProjects/TowerFinisher/AndEngine/src/main/java/org/andengine/opengl/texture/atlas/bitmap/source/decorator/ColorSwapBitmapTextureAtlasSourceDecorator.java
Error:(7, 24) error: cannot find symbol class AvoidXfermode
Error:(8, 38) error: package android.graphics.AvoidXfermode does not exist
Error:(70, 31) error: cannot find symbol class AvoidXfermode
Error:(70, 86) error: cannot find symbol variable Mode
/home/neelpatel104/AndroidStudioProjects/TowerFinisher/AndEngine/src/main/java/org/andengine/opengl/font/StrokeFont.java
Error:(76, 36) error: cannot find symbol method floor(float)
/home/neelpatel104/AndroidStudioProjects/TowerFinisher/AndEngine/src/main/java/org/andengine/entity/particle/ParticleSystem.java
Error:(181, 111) error: cannot find symbol method floor(float)
/home/neelpatel104/AndroidStudioProjects/TowerFinisher/AndEngine/src/main/java/org/andengine/entity/particle/emitter/CircleParticleEmitter.java
Error:(50, 54) error: cannot find symbol method cos(float)
Error:(51, 54) error: cannot find symbol method sin(float)
/home/neelpatel104/AndroidStudioProjects/TowerFinisher/AndEngine/src/main/java/org/andengine/entity/particle/emitter/CircleOutlineParticleEmitter.java
Error:(50, 54) error: cannot find symbol method cos(float)
Error:(51, 54) error: cannot find symbol method sin(float)
/home/neelpatel104/AndroidStudioProjects/TowerFinisher/AndEngine/src/main/java/org/andengine/entity/modifier/PathModifier.java
/home/neelpatel104/AndroidStudioProjects/TowerFinisher/AndEngine/src/main/java/org/andengine/engine/camera/hud/controls/AnalogOnScreenControl.java
Error:(85, 39) error: cannot find symbol method cos(float)
Error:(85, 71) error: cannot find symbol method sin(float)
Error:Execution failed for task ':AndEngine:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Information:BUILD FAILED
Information:Total time: 1 mins 40.808 secs
Information:55 errors
Information:0 warnings
Information:See complete output in console

我不明白问题是什么。每次我尝试调试程序时都存在此错误。我什至试图重新安装和发动机和tmtaxiledmap扩展名,但是错误始终存在。如果有人看它,我会喜欢的。

构建失败了,因为某些类和方法在最新版本中被弃用。您可以尝试为您的AndEngine build.gradle文件降低compilesdkversion。另外,您可以通过简单更改来解决大多数这些错误:

  1. 通过使用标准数学类更改所有数学调用,例如SIN,COS,FLOORT,SQRT,CEIL等:替换 floatmath.sin() to (float)Math.sin.sin()和其他方法类似。
  2. 修复软件包org.apache.http不存在错误:添加 USELIBRARY'org.apache.http.legacy' to andEngine build.gradle file.gradle file.gradle file:

    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.0.0'
        }
    }
    apply plugin: 'com.android.library'
    android {
        compileSdkVersion 23
        //buildToolsVersion '26'
        sourceSets {
            main {
                manifest.srcFile 'AndroidManifest.xml'
                java.srcDirs = ['src']
                resources.srcDirs = ['src']
                res.srcDirs = ['res']
                assets.srcDirs = ['assets']
            }
        }
        useLibrary 'org.apache.http.legacy' //for support 23+ sdk
    }
    ...
    
  3. class deverxfermode被弃用,因此 compilesdkversion 23 如上所述。如果有人描述如何以其他方式修复避免使用的方式,我将不胜感激。

相关内容

  • 没有找到相关文章

最新更新