何时使用CC_CONTENT_SCALE_FACTOR()? [英] When to use CC_CONTENT_SCALE_FACTOR()?

查看:444
本文介绍了何时使用CC_CONTENT_SCALE_FACTOR()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对于在我的应用程序中使用CC_CONTENT_SCALE_FACTOR()有点困惑。我使用Box2D进行碰撞检测,我做了一个b2Body的顶点。现在我应该仅通过PTM_Ratio还是通过PTM_Ratio乘以CC_CONTENT_SCALE_FACTOR()?

I am a bit confused on when to use CC_CONTENT_SCALE_FACTOR() in my app. I use Box2D for collision detection, and I make a b2Body of vertices. Now should I divide each point only by the PTM_Ratio or by the PTM_Ratio multiplied by CC_CONTENT_SCALE_FACTOR()?

我应该在我的应用程序的任何地方使用CC_CONTENT_SCALE_FACTOR处理像素?我应该只为这样的GLESDebugDraw使用CC_CONTENT_SCALE_FACTOR()吗?

Should I be using CC_CONTENT_SCALE_FACTOR() anywhere in my app if I am not dealing with pixels? Should I only use CC_CONTENT_SCALE_FACTOR() for GLESDebugDraw like this?

_debugDraw = new GLESDebugDraw(ptmRatio * CC_CONTENT_SCALE_FACTOR());

谢谢!

推荐答案

Box2D world doesn' Box2D完全忽略屏幕分辨率,因此你不应该也不应该缩放任何内容,无论你是否在Retina显示设备上。

The Box2D world doesn't care in how many pixels it is rendered in. Box2D is completely oblivious to screen resolution, therefore you don't and shouldn't scale any content whether you're on a Retina display device or not.

目前只有一个方面,您可能需要CC_CONTENT_SCALE_FACTOR,这是使用tilemaps时。如果我记得正确,tileset宽度和高度属性以像素而不是点。因此,您需要除以CC_CONTENT_SCALE_FACTOR以获得正确的点大小。不知道为什么这不是由cocos2d内部做的。

There's currently only one aspect where you might need CC_CONTENT_SCALE_FACTOR and that is when working with tilemaps. If I remember correctly, the tileset width and height properties are given in pixels, not points. Therefore you need to divide by CC_CONTENT_SCALE_FACTOR to get the correct size in points. Not sure why that's not done by cocos2d internally.

这篇关于何时使用CC_CONTENT_SCALE_FACTOR()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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