- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试更新我的项目以使用 AndEngine GLES2 运行,但我遇到了一些问题。我找到了一篇文章,其中显示了要更改的内容,但它仍然无法正常工作。这正是我正在做的:
onCreateEngineOptions()
@Override
public EngineOptions onCreateEngineOptions() {
Toast.makeText(this, "Touch the screen to add Logo.", Toast.LENGTH_LONG).show();
CAMERA_WIDTH = getWindow().getWindowManager().getDefaultDisplay().getWidth();
CAMERA_HEIGHT = getWindow().getWindowManager().getDefaultDisplay().getHeight();
final Camera camera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
final EngineOptions engineOptions = new EngineOptions(true, ScreenOrientation.PORTRAIT_FIXED, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), camera);
engineOptions.getTouchOptions().setNeedsMultiTouch(false);
return engineOptions;
}
onCreateResources()
public void onCreateResources() {
this.mBitmapTextureAtlas = new BitmapTextureAtlas(4096, 4096, TextureOptions.BILINEAR_PREMULTIPLYALPHA);
this.mFont = new Font(this.mBitmapTextureAtlas, Typeface.create(Typeface.DEFAULT, Typeface.NORMAL), 25, true, Color.BLACK);
this.mEngine.getTextureManager().loadTexture(this.mBitmapTextureAtlas);
this.mEngine.getFontManager().loadFont(this.mFont);
this.firstSprite = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mBitmapTextureAtlas, this, "1.png", 0, 113); // 113x100
// 36 other sprites, that's why I'm creating BitmapTextureAtlas with these size
this.mEngine.getTextureManager().loadTexture(this.mBitmapTextureAtlas);
}
onCreateScene()
@Override
public Scene onCreateScene() {
this.mEngine.registerUpdateHandler(new FPSLogger());
this.mScene = new Scene();
this.mScene.setBackground(new Background(4, 4, 4));
this.mScene.setOnSceneTouchListener(this);
this.mPhysicsWorld = new PhysicsWorld(new Vector2(0, SensorManager.GRAVITY_EARTH), false);
CAMERA_WIDTH = getWindow().getWindowManager().getDefaultDisplay().getWidth();
CAMERA_HEIGHT = getWindow().getWindowManager().getDefaultDisplay().getHeight();
final IAreaShape ground = new Rectangle(0, CAMERA_HEIGHT - 2, CAMERA_WIDTH, 2);
final IAreaShape roof = new Rectangle(0, 0, CAMERA_WIDTH, 2);
final IAreaShape left = new Rectangle(0, 0, 2, CAMERA_HEIGHT);
final IAreaShape right = new Rectangle(CAMERA_WIDTH - 2, 0, 2, CAMERA_HEIGHT);
final FixtureDef wallFixtureDef = PhysicsFactory.createFixtureDef(0, 0.5f, 0.5f);
PhysicsFactory.createBoxBody(this.mPhysicsWorld, ground, BodyType.KinematicBody, wallFixtureDef);
PhysicsFactory.createBoxBody(this.mPhysicsWorld, roof, BodyType.KinematicBody, wallFixtureDef);
PhysicsFactory.createBoxBody(this.mPhysicsWorld, left, BodyType.KinematicBody, wallFixtureDef);
PhysicsFactory.createBoxBody(this.mPhysicsWorld, right, BodyType.KinematicBody, wallFixtureDef);
this.mScene.attachChild(ground);
this.mScene.attachChild(roof);
this.mScene.attachChild(left);
this.mScene.attachChild(right);
this.mScene.registerUpdateHandler(this.mPhysicsWorld);
this.mScene.setOnAreaTouchListener(this);
final FixtureDef objectFixtureDef = PhysicsFactory.createFixtureDef(1, 0.5f, 1);
//Sprite 1
Sprite face = new Sprite(CAMERA_WIDTH/2, 50, this.firstSprite);
face.setUserData("petrol");
Body body = PhysicsFactory.createCircleBody(this.mPhysicsWorld, face, BodyType.DynamicBody, objectFixtureDef);
this.mScene.registerTouchArea(face);
this.mScene.attachChild(face);
this.mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(face, body, true, true));
// 36 sprites....
return this.mScene;
}
问题是,当我开始这个 Activity 时,它没有显示任何 Sprite ,即使我将它更改为白色,屏幕仍然是黑色的。
所以任何想法我的错误在哪里以及我做错了什么。 (在迁移到 AndEngine GLES2 之前,除 Android Honeycomb 外,其他一切正常,现在我正在运行 Android 2.3.4 的 HTC EVO 3d 上测试这个项目)。
提前致谢!
最佳答案
我不确定这是否是你的问题 - 我在添加之前遇到过类似的问题
@Override
public void onPopulateScene(Scene pScene, OnPopulateSceneCallback pOnPopulateSceneCallback) throws Exception { //
// TODO Auto-generated method stub
pOnPopulateSceneCallback.onPopulateSceneFinished();
}
关于android - AndEngine 导入 GLES2 项目未运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8882234/
我目前正在尝试在 Android 上开发视频播放器,但在颜色格式方面遇到困难。 上下文:我通过 MediaExtractor/MediaCodec 的标准组合提取和解码视频。因为我需要将提取的帧用作
给定下一个顶点着色器,什么是最简单、最有效和最快的颠倒坐标的方法,这样片段着色器就会产生颠倒的图像? attribute vec4 a_position; attribute vec2 a_texco
我正在尝试使用 gles 2 在 android 中绘制一些 3d 线。但它导致了一些奇怪的效果。当我旋转场景/相机时会发生闪烁。但不仅如此,还有一些随机绘制的 2d 线(有时是点)。这是屏幕截图:
我正在使用 OpenGL ES 3.0 渲染剪辑坐标中提供的许多三角形。我使用 varying 为每个片段生成内插纹理坐标。但是,由于插值使用顶点的 z 坐标,因此插值在屏幕空间中不是线性的。据我所知
我正在使用 SurfaceView 通过 GLES 将相机预览渲染到屏幕上。是否可以在渲染之前用下面的方法裁剪纹理?我想裁剪 16:9 的纹理以在屏幕上显示为 4:3。 public void dra
尝试在启用了 gpu 仿真的 4.0.3 模拟器上运行 OpenGLES 2 应用程序时,我不断收到此错误: Failed to create Context 0x3005 emulator: WAR
我正在用 android 制作游戏,但颜色太亮而且我无法更改 Sprite ,所以我决定实现一个着色器: const char* fETCShader = "\ uniform mediump sam
我正在使用统一变量将浮点值传递到 GLES 着色器,但我的代码一直生成 1282 错误。我在这里遵循了几个示例,并且非常确定我做的一切都是正确的。你能发现我的代码有什么问题吗?我正在 Nexus 7
我有一个二维 float 组(在本例中,它代表一个具有 R G B 值的 256 色调色板) static float[][] glColorPaletteArray = new float[256]
我完全无法编写一个在 Android Studio 中绘制三角形的简单 GLES 3.0 应用程序。虽然我在用 C++ 编写普通现代 OpenGl 程序方面有很多经验,但我无法弄清楚为什么我的代码不起
在OpenGL ES 3.2中,有如下函数 //for simplify I omit the params GLuint glGetProgramResourceIndex(...); void g
如何将“普通”矩形转换为一组 OpenGL ES 顶点。我不擅长几何学,所以我不知道顶点是如何工作的,我希望能够操纵矩形,而不必通过反复试验计算出顶点的值。 我基本上需要转换这个结构: typedef
我在 GLES-Render 中收到 8 个警告,它们都是关于同一件事的: setUniformForModelViewProjectionMatrix 已弃用。 就在这里: [mShaderProg
您好,我正在尝试制作一款双人乒乓球游戏,但其中的多点触控部分无法正常工作,我知道我使用的设备支持多点触控,因此我的代码中一定有问题。现在我有两个专用的背景部分,当触摸它们时设置桨的位置但是如果有人的手
简而言之,我将两个开源应用程序合并到一个新的 VR 应用程序中,因此它只能在使用 GearVR 耳机的 Note 4 和 S6 上运行。我的应用程序适用于 kitkat,但视频在 Lollipop 上
我是 OpenGL 的新手,正在寻找任何用于在屏幕上绘制简单 UIImage 的代码片段 - 与 UIImageView 完全一样。 互联网上到处都是这样的代码示例,但它们都为图片添加了一点平滑效果,
GLES 2.0 调用在 Android 和 iOS 上是同步的还是异步的?它什么时候会阻塞 CPU 等待 GPU 完成发送的命令?我相信 glReadPixels 和 glGetTexImage 肯
我正在制作一款即将上市的应用程序,但我想知道,我应该使用 Canvas 还是 Open GLES?现在我不知道如何使用开放式 GLES。我使用 canvas 大约有一年了,我听说 open GLES
我想学习 OpenGL 来用 C 语言编写游戏,但我对选择哪个库有点困惑,目的是生成一个包含游戏逻辑的 C 库,并使用 Android NDK 与手机中的资源进行交互。 我找到了一个使用 GLESv2
我正在使用 AndEngine GLES 2 为 Android 编写游戏。一切正常 - 我有一个背景图像,有四处移动的 Sprite ,甚至还有一些音乐 - 直到最近我尝试了一些新的东西(我希望能够
我是一名优秀的程序员,十分优秀!