- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
在我的情况下,我没有使用 RenderSurfaceView。我想对我的场景进行屏幕截图。但是当我保存屏幕截图时,它显示倒置的镜像。无法理解我在这里做错了什么。
这是我的代码
attachChild(screenCapture);
share_clicked = 1;
final int viewWidth = (int)camera.getWidth();
final int viewHeight = (int)camera.getHeight();
Log.d("camera width", "View width :" + viewWidth);
Log.d("camera height", "View height :" + viewHeight);
File direct = new File(
Environment.getExternalStorageDirectory()
+ "/Word");
if (!direct.exists()) {
if (direct.mkdir())
; // directory is created;
}
screenCapture.capture(
viewWidth,
viewHeight,
direct.getAbsolutePath() + "/word"
+ System.currentTimeMillis() + ".png",
new IScreenCaptureCallback() {
public void onScreenCaptured(
final String pFilePath) {
activity
.runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(
activity,
"Image Successfully saved to 'Word' folder in SD Card.",
Toast.LENGTH_SHORT)
.show();
}
});
}
public void onScreenCaptureFailed(
final String pFilePath,
final Exception pException) {
activity.runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(
activity,
"Failed saving the image! Please check SD card.",
Toast.LENGTH_SHORT)
.show();
}
});
}
});
![这是我得到的屏幕截图1
如果有人能帮我找到这个,那将是一个很大的帮助。谢谢。
最佳答案
更新 GLES2-AnchorCenter
AndEngine/src/org/andengine/entity/util/ScreenGrabber.java
private static Bitmap grab(final int pGrabX, final int pGrabY, final int pGrabWidth, final int pGrabHeight) {
final int[] pixelsRGBA_8888 = new int[pGrabWidth * pGrabHeight];
final IntBuffer pixelsRGBA_8888_Buffer = IntBuffer.wrap(pixelsRGBA_8888);
// TODO Check availability of OpenGL and GLES20.GL_RGBA combinations that require less conversion operations.
GLES20.glReadPixels(pGrabX, pGrabY, pGrabWidth, pGrabHeight, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, pixelsRGBA_8888_Buffer);
/* Convert from RGBA_8888 (Which is actually ABGR as the whole buffer seems to be inverted) --> ARGB_8888. */
final int[] pixelsARGB_8888 = GLHelper.convertRGBA_8888toARGB_8888(pixelsRGBA_8888);
final int[] pixels = new int[pGrabWidth * pGrabHeight];
for (int y = 0; y < pGrabHeight; y++) {
for (int x = 0; x < pGrabWidth; x++) {
pixels[x + ((pGrabHeight - y - 1) * pGrabWidth)] = pixelsARGB_8888[x + ((pGrabY + y) * pGrabWidth)];
}
}
return Bitmap.createBitmap(pixels, pGrabWidth, pGrabHeight, Config.ARGB_8888);
}
关于android - andengine中的屏幕截图给出了颠倒的镜像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16620325/
我正在使用 andengine 开发游戏,我对加载屏幕感到震惊。每次按下我的菜单项时,加载下一个事件需要一些时间,同时出现黑屏,所以任何人都可以帮助我设置带有加载文本的屏幕而不是黑屏。 我搜索了一下,
您知道是否有任何教程或示例展示如何处理游戏的多个屏幕/场景? 例如,假设我有一个具有以下结构的游戏: 封面 主菜单 玩法 积分 将所有代码放在一个 java 文件中可能是一场噩梦......我想使用不
我是 AndEngine 的新手。从 a AndEngine Tutorial 工作时,未找到以下类。我尝试从 AndEngine 导入所有库,但仍未找到类。 类(class)是: SimpleLev
我对 andengine 非常陌生,尝试使用 git url 中的 andengine 示例:https://github.com/nicolasgramlich/AndEngineExamples
我希望在我的游戏中创建屏幕控件,但我不知道如何创建屏幕控件。 我的疑问是: 如何创建屏幕控件? 屏幕控件应该在我们的游戏项目中的什么位置实现? 屏幕控件的类型? 现在我正在创建这个游戏。我有一个球,但
所以,我正在研究 AndEnginePhysicsExample 代码。我想知道这个方法的含义是什么(http://pastebin.com/Day2hciB): private void addFa
我想从菜单开始游戏。在 Eclipse 中,我有 2 个项目,一个是菜单,另一个是实际的游戏。两者都使用 SimpleBaseGameActivity 作为基础。网上的例子做了如下所示的事情。特别是,
我创建这个池是为了回收和重用我添加到场景中的 Sprite 正如您将在我的代码中看到的,我创建了自己的获取方法,该方法随机化选择出现在场景中的 Sprite ,并随机化其 x 位置。问题是,它似乎出于
我的级别选择器出现问题。我正在使用我在该论坛的教程中找到的代码,但它无法正常工作。 事实是,当用户混合播放时,我正在使用两个场景,我将引擎设置为第二个场景,然后用户可以滚动级别。 然后,当用户按下后退
我有一个 GameScene,其中使用了 ZoomCamera、一个背景和一些“病毒”。问题是,当我放大或缩小背景时,背景也会缩放,我不希望这样,请帮忙。 http://puu.sh/9XPUl/c6
所以,这里的想法是收集三根日志,简单的任务。但我只能按特定顺序获取日志,否则触摸日志会使应用程序崩溃。为什么?如果我按顺序捕获它们,它就会起作用,但如果我先触摸日志 2 或 3,它就会崩溃。有更好的方
我正在学习如何使用 box2d 和 andEngine。我试图让我的 Sprite body 移动。我之前在 onCreateScene 中编写所有内容时就让它工作了,但现在我想为我的 Sprite
当用户在屏幕上交换手指时,我想显示一个三角形条。我不知道如何使用 AndEngine、使用粒子系统或使用 Sprite 或使用三角带算法... 我没有写任何代码,因为我很震惊该怎么做。我正在上传图片,
好吧,我正在提供这个变量来为 andengine 中的 sprite 表设置动画。 player.animate(new long[] { 100,100},0,2,false); 它采用的第一个
当在设备中加载时只有白色图像显示,当加载模拟器时图像被破坏 示例代码: // this.mCamera = new Camera(0, 0, 480,320); final Engine en
我开始在我的应用中使用 AndEngine。我使用了一个 xml 来定义应用程序的基本样式。我已经定义了一个场景,其中有一些可拖动的 Sprite 。 我已经正确导入了 xml,但场景出现在它上面,背
我试过这里的东西, http://www.andengine.org/forums/tutorials/getting-started-with-andengine-t11.html jar 文件 4
我仍在学习如何使用出色的 AndEngine 并进行了一些搜索,但我找不到如何创建像跳转到“超空间”这样的效果的示例。效果不必像在星球大战中看到的那样复杂,但可以像旧的 Windows“星星”屏幕保护
我使用的是Android 4.2.2。在我从 github 导入 andengine 并修复错误后,我制作了我的项目。之后我去了图书馆,添加了 andengine,一切都很好。 http://s29.
我在使用 ChangableText 时遇到问题,我正在使用它来显示当前分数。 但是它有问题,因为它在更新时速度很慢。但是,达到 90 分后,更新文本时不再有滞后......(只有前 9x10 分)
我是一名优秀的程序员,十分优秀!