如何在AndEngine中决定SVG精灵的宽度和高度
我正在使用 AndEngine 加载 svg 图像作为我的 Sprites。
我遇到的问题是我无法弄清楚如何缩放图像以适应运行它的特定设备。
sprite= new Sprite(positionX, positionY, WIDTH,HEIGHT,TextureRegion);
它采用的参数是 x 和 y 坐标上的位置,然后是宽度和高度。
我遇到的问题是我无法弄清楚如何将精灵缩放到我想要的正确宽度和高度。
例如,我有一个标题,我希望标题在更大的设备上更大,我如何决定设备是否更大,并针对更大的屏幕放大它,针对更小的屏幕缩小标题?
I am using AndEngine to load a svg images as my Sprites.
The problem I am having with this is that i can't figure out how to scale the image to fit the particular device on which it is being run.
sprite= new Sprite(positionX, positionY, WIDTH,HEIGHT,TextureRegion);
The parameters that it takes are the position's on x and y coordinates, and then width, and height.
The problem I am having is that I can't figure out how to scale the sprite to the right width and height for how I want it.
For example I have a title, and I want the title to be bigger on bigger devices, how would I decide if the device is bigger and scale it up for a bigger screen and down for a smaller screen?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用恒定的相机尺寸,则所有屏幕都会缩放(因此所有实体)。
确定一个恒定的大小,例如
720x480
。然后,在创建引擎选项时,使用:
在每个设备上,相机将自行缩放以尽可能适合分辨率,同时保持宽度与宽度之间的比率。高度。
现在,在创建精灵时,只需执行以下操作:
不要指定精灵大小!它相对于相机尺寸的大小将根据纹理区域的大小来决定,并且它将是一个常数。 然后,它将被相机缩放为- 设备屏幕缩放,从一个设备到另一个设备会发生变化,但比例将保持不变 - 在分辨率与相机宽度/高度比不同的设备上,游戏不会看起来像糟糕的缩放图像。
我认为AndEngine提供了一个很好的方法来处理不同的屏幕分辨率;恕我直言,这是最好使用的。
If you use a constant camera size, all of the screen is scaled (Hence all of the entities).
Decide on a constant size, for exaple
720x480
.Then, when creating the engine options, use:
On each device, the camera will scale itself to fit the resolution as good possible, while keeping the ratio between width & height.
Now, when creating a sprite, just do:
Don't give the sprite size! Its size comparing to the camera size will be decided according to the texture region size, and it will be a constant one. Then, it will be scaled by the camera-to-device-screen scaling, which changes from one device to another, but the ratio will remain constant - the game will not look like a bad scaled image on devices with a different resoltuion that the camera width/height ratio.
I think that's a great method that AndEngine provides to deal with different screen resolution; IMHO, it is the best to use.