首页 \ 问答 \ libgdx视口适合不同的屏幕(libgdx viewport fit different screens)

libgdx视口适合不同的屏幕(libgdx viewport fit different screens)

我在不同屏幕上安装游戏时遇到问题。 我在舞台类中声明了视口宽度和高度。

public static final int VIEWPORT_WIDTH = 20;
public static final int VIEWPORT_HEIGHT = 30;

我安装了相机

camera = new OrthographicCamera(VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
camera.position.set(camera.viewportWidth/2, camera.viewportHeight/2, 0f);

我在桌面应用程序中将屏幕宽度和高度设置为此

public static final int APP_WIDTH = 800;
public static final int APP_HEIGHT = 900;

在桌面上一切看起来很好,但在我的Android设备上,它看起来向上伸展。 我阅读了有关视口的文档但是如何使用这些变量在这里实现呢? 我知道有类似的问题,但我想知道可以使用这些特定变量来实现视口,这样我可能会更好地理解它。


I'm having a problem with fitting my game on different screens. I declared a viewport width and height in my stage class.

public static final int VIEWPORT_WIDTH = 20;
public static final int VIEWPORT_HEIGHT = 30;

And i set up the camera

camera = new OrthographicCamera(VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
camera.position.set(camera.viewportWidth/2, camera.viewportHeight/2, 0f);

And i set the screen width and height in desktop app to this

public static final int APP_WIDTH = 800;
public static final int APP_HEIGHT = 900;

On desktop everything looks fine but on my android device it looks stretched upwards. I read the documentation about viewports but how can I implement it here using these variables? I know similar questions have been asked but I would like to know viewports can be implemented using these specific variables, that way I might understand it better.


原文:https://stackoverflow.com/questions/43388088
更新时间:2022-02-28 07:02

最满意答案

ASB是关于消息。 您使用消息传递来部分系统/服务之间的通信。 RESTful服务可以通过将请求转换为消息来执行某些工作来利用ASB。 强调将意图转化为信息,指导需要进行的工作,而不是执行工作本身。

ASB或ASQ是您的选择。 这是您需要在各自提供的功能和功能之间进行选择的位置。 这里有一个很好的MSFT 比较文档

队列与主题/订阅 - 如果您需要将消息发送到单个目标(命令),则队列更简单。 如果需要将消息广播到多个接收者(事件),则主题/订阅是您的朋友。


ASB is about messaging. You use messaging for communication between parts of your system/services. RESTful services can leverage ASB by translating a request into a message to perform some work. Emphasis on converting the intent into a message, to instruct about work that needs to take place, not execute the work itself.

ASB or ASQ is your choice. This is where you need to choose between the features and capabilities each provides. There's a good MSFT comparison documentation on it.

Queues vs Topics/Subscriptions - if you need to send a message to a single destination (a command) then queue is simpler. In case a message needs to be broadcasted to multiple receivers (events), topics/subscriptions are your friends.

相关问答

更多
  • 为了在运行时查找控制器类,可以像这样编写一个程序集解析器。 public class MyAssembliesResolver : DefaultAssembliesResolver { public override ICollection GetAssemblies() { List assemblies = new List(base.GetAssemblies()); // Add all ...
  • 首先,我认为创建自己的认证机制绝不是一个好主意。 回答您当前的问题: 1通常说来,您总是希望使用身份验证来保护您的Api,因为它是您访问数据的地方。 你的客户端(MVC App / Smartphone)应该授权自己访问你的Api。 2&3因为您使用的是REST API,我建议让您的Api无状态,换句话说,不要保留任何会话信息。 只需在您的令牌中包含您需要的角色数据。 您可以使用例如JSON Web令牌 。 4我总是使用授权头来发送授权数据。 在您的DelegatingHandler中(请注意Message ...
  • 我们过去做过的一件事是创建一个端点“ http://webapi.com/twitter/200/name ”,然后执行包含更新值的put。 它并不完美,但它完成了工作并且很容易实现。 Think I found a solution with Newtonsoft JsonConvert.PopulateObject Populate Object
  • 在过去十年中,物理分层被认为是一件好事。 N级很好。 这里的要点是每一层都应该提供一个真正的价值 。 仅仅为了分层的层是不好的。 所以历史上我们在做: DB =>提供数据 中间层=>提供服务(应用于数据的业务逻辑) ASP.NET网站(表示层)=>提供渲染视图 现在,通过SPA和新的支持js的富客户端, 可以在客户端上呈现视图 。 因此,服务的表示层现在是冗余的(尽管低端客户端可能仍然需要)。 我对典型的非BigData场景的建议是2个物理层 : DB =>提供数据 服务层=>提供服务 在服务层,我们将有3 ...
  • 绝对没有什么能阻止您使用ASP.NET Web API的服务总线。 我正在实现这个(web api)我正在实现的项目,用户注册,我需要发送激活电子邮件。 从服务总线端点处理电子邮件发送,以便从web api立即返回注册。 我还在生产系统中实现了我的服务总线,尽管它是MVC 3(4个Web服务器)。 虽然任何服务总线应该可以解决问题(NServiceBus,MassTransit等),但您可能需要查看我的FOSS Shuttle ESB项目: http ://shuttle.codeplex.com/ The ...
  • Web API提供了对HTTP交互的所有方面的更多访问。 它是在HTTP规范的基础上设计的。 如果您只是使用HTTP来通过防火墙,WCF就可以了。 如果您真的想使用HTTP作为应用程序协议,您会发现Web API更容易。 Web API provides far more access to all aspects of the HTTP interaction. It was designed from the ground up around the HTTP spec. WCF is fine if ...
  • 我正在考虑如何将它用于非基于http的客户端 好吧,它不能。 Web API仅适用于HTTP协议。 如果您需要使用其他传输协议(如UDP),则可以考虑使用WCF。 我们如何提供有关API的代理信息 RESTful服务没有代理信息的概念。 对于非.NET客户端,应该很好地记录它们。 对于.NET客户端,您可以在服务器和客户端应用程序之间共享合同(请求/响应Dto)。 然后,客户端应用程序可以重用那些可能充当您所谓的代理的 Dtos,这些内容存在于SOAP世界中但不存在于REST世界中。 Straight aw ...
  • 这绝对是可能的。 您可以使用Azure App Service Mobile Apps服务来运行您的服务。 这提供了与Azure移动服务相同的功能,但完全包含在ASP.NET Web App(或Node.js Web应用程序)中。 它只是ASP.NET应用程序之上的SDK。 有关此内容的更多信息,请参阅文档 。 This is definitely possible. You can use the Azure App Service Mobile Apps service to run your serv ...
  • ASB是关于消息。 您使用消息传递来部分系统/服务之间的通信。 RESTful服务可以通过将请求转换为消息来执行某些工作来利用ASB。 强调将意图转化为信息,指导需要进行的工作,而不是执行工作本身。 ASB或ASQ是您的选择。 这是您需要在各自提供的功能和功能之间进行选择的位置。 这里有一个很好的MSFT 比较文档 。 队列与主题/订阅 - 如果您需要将消息发送到单个目标(命令),则队列更简单。 如果需要将消息广播到多个接收者(事件),则主题/订阅是您的朋友。 ASB is about messaging. ...
  • 基本上,您必须首先将RhinoServiceBusFacility / AbstractRhinoServiceBusFacility重写为Ninject模块。 然后在其他文件中也有Castle引用,例如DefaultServiceBus引用了IKernel,应该更改为使用Ninject的内核。 Basically, you'd have to start by rewriting RhinoServiceBusFacility / AbstractRhinoServiceBusFacility as a ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)