- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我在使用 andengine. 开发的简单游戏中为菜单页面设置了 bg
I have Set the bg as
public class MenuActivity extends SimpleBaseGameActivity implements
IOnMenuItemClickListener {
private static int CAMERA_WIDTH = 480;
private static int CAMERA_HEIGHT = 800;
private Camera mCamera;
private ITextureRegion mBackgroundTextureRegion;
protected static final int MENU_RESET = 0;
protected static final int MENU_QUIT = MENU_RESET + 1;
private Font mFont;
protected MenuScene mMenuScene;
private Scene mScene;
@SuppressWarnings("deprecation")
@Override
public EngineOptions onCreateEngineOptions() {
final Display display = getWindowManager().getDefaultDisplay();
this.mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
return new EngineOptions(true, ScreenOrientation.PORTRAIT_FIXED,
new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT),
this.mCamera);
}
@Override
protected void onCreateResources() {
BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
try {
ITexture backgroundTexture = new BitmapTexture(
this.getTextureManager(), new IInputStreamOpener() {
@Override
public InputStream open() throws IOException {
return getAssets().open("gfx/bg3.png");
}
});
backgroundTexture.load();
this.mBackgroundTextureRegion = TextureRegionFactory
.extractFromTexture(backgroundTexture);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
protected Scene onCreateScene() {
this.mEngine.registerUpdateHandler(new FPSLogger());
this.mScene = new Scene();
Sprite backgroundSprite = new Sprite(0, 0,
this.mBackgroundTextureRegion, getVertexBufferObjectManager());
// this.mScene.attachChild(backgroundSprite);
this.mScene.setBackground(new SpriteBackground(backgroundSprite));
return this.mScene;
}
and the bg is not fit to the screen it has some empty spaces in both left and right ends. How to solve this,?
最佳答案
BaseResolutionPolicy 决定 AndEngine 如何处理我们应用程序的显示宽度和基于各种因素的高度:
FillResolutionPolicy: The FillResolutionPolicy class is the typical resolution policy if we simply want our application to take up the full width and height of the display. It may cause some noticeable stretching in order for our scene to take up the full available dimensions of the display.
FixedResolutionPolicy: The FixedResolutionPolicy class allows us to apply a fixed display size for our application, regardless of the size of the device's display or Camera object dimensions. This policy can be passed to EngineOptions via new FixedResolutionPolicy(pWidth, pHeight), where pWidth defines the final width that the application's view will cover, and pHeight defines the final height that the application's view will cover.
RatioResolutionPolicy: The RatioResolutionPolicy class is the best choice for resolution policies if we need to obtain the maximum display size without causing any distortion of sprites. On the other hand, due to the wide range of Android devices spanning many display sizes, it is possible that some devices may see "black bars" either on the top and bottom, or left and right sides of the display.
RelativeResolutionPolicy: This is the final resolution policy. This policy allows us to apply scaling, either larger or smaller, to the overall application view based on a scaling factor with 1f being the default value.
因此,如果您想要全屏,请像这样使用 FillResolutionPolicy:
EngineOptions engineOptions = new EngineOptions(true,
ScreenOrientation.LANDSCAPE_FIXED, new FillResolutionPolicy(),
mCamera);
关于android - andengine activity bg 不适合屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18201244/
我正在使用 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 分)
我是一名优秀的程序员,十分优秀!