AndEngine相机和设备显示:在每个坐标之间的比率 [英] AndEngine camera and Device display : Ratio between co-ordinates on each

查看:186
本文介绍了AndEngine相机和设备显示:在每个坐标之间的比率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的的FrameLayout上的 Andengine相机顶部添加一个按钮。我需要对齐按钮,将andengine相机精灵。

I'm using a FrameLayout on top of Andengine camera to add a button. I need to align the button to a sprite on the andengine camera.

我使用重力顶部的框架布局并添加顶部填充,以向下移动的按钮。工作的,而显影装置上。但由于在 RatioResolutionPolicy ,具有不同的屏幕尺寸不同的设备上,对齐不起作用。

I'm using gravity top in the frame layout and adding top padding to shift the button down. Works while on the development device. But because of the RatioResolutionPolicy, on a different device with different screen size, the alignment does not work.

我想知道如何找到设备屏幕显示坐标,将正好与AndEngine摄像机坐标重合。我试图找出的比例和分配填充,但不工作。任何人都可以指导我如何找到在屏幕上显示的坐标将与AndEngine相机上的坐标精确重合?

I am wondering how to find the device screen Display co-ordinates that would exactly coincide with the AndEngine camera co-ordinates. I tried to figure out the ratio and assign the padding but is not working. Can anyone guide me on how to find the co-ordinates on the screen Display that would coincide exactly with the co-ordinates on the AndEngine camera?

真的坚持了这一点,因为两天。任何帮助将大大AP preciated。

Really stuck with this since two days. Any help would be greatly appreciated.

最近的我就是用这个达到(按钮的变化,但是这仍然是不准确):

Closest i reached was using this (Button shifts but this is still not exact):

    //get actual screen height of device to find ratio
    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int height = size.y;
    int width = size.x;

    //normal ratio logic
    int heigntUsedByCamera = width * CAMERA_HEIGHT / CAMERA_WIDTH;
    int requiredPaddingForBtnOnFrameLayout = (height - heigntUsedByCamera)/2;

在这一个我期待的按钮X是完全CAMERA开始的地方。

In this one I'm expecting the button X to be exactly where the CAMERA starts

这是怎么回事错在这里?

What is going wrong here?

或是否有更好的方法来添加AndEngine相机内的本地按钮?

推荐答案

由于,它大部分时间情况发生,找到了解决办法喽。

As, it most of the time happens, found the solution myself.

就像我在我的问题中提到的code上面让我接近的结果,但不准确。我想通了偏差,因为我有缩放按钮来0.6f。删除了缩放,它是完​​美的工作。

Like i mentioned in my question the code above was getting me close results but not accurate. I figured the deviation was because i had scaled the button to 0.6f. Removed the scaling and it is working perfect.

这篇关于AndEngine相机和设备显示:在每个坐标之间的比率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆