Difference between revisions of "love.window.fromPixels (简体中文)"
m (Fixed parent) |
|||
Line 41: | Line 41: | ||
== See Also == | == See Also == | ||
− | * [[parent::love.window]] | + | * [[parent::love.window (简体中文)]] |
* [[love.window.toPixels]] | * [[love.window.toPixels]] | ||
* [[love.window.getPixelScale]] | * [[love.window.getPixelScale]] |
Revision as of 17:41, 8 May 2016
Available since LÖVE 0.9.2 |
This function is not supported in earlier versions. |
把数字从像素单位转换为像素密度无关单位。
窗口内的像素密度可能比窗口的“大小”更大(或更小)。例如通过love.window.setMode 启用在Mac OS X 上的Retina屏幕的highdpi
,窗口会使用相同的800x600的物理窗口大小,但窗口的内部区域使用1600x1200像素。
那样的话love.window.fromPixels(1600)
将返回 800
。
这个函数转换坐标从像素到用户期望的在屏幕上显示的大小。love.window.toPixels函数则相反。在Mac OS X 和 iOS平台上,highdpi
的window flag必须被启用,以使用Retina屏幕的全像素密度。
这个标志在Windows 和 Linux上不产生影响,但在Android上总是启用的。
大多数的 LÖVE 函数返回值及参数期待像素单位而不是像素无关单位。
(Most LÖVE functions return values and expect arguments in terms of pixels rather than density-independent units. )
Contents
Function
Synopsis
value = love.window.fromPixels( pixelvalue )
Arguments
number pixelvalue
- 将要转换成像素无关单位的一个以像素为单位的数字。
Returns
number value
- The converted number, in density-independent units.
Function
Synopsis
x, y = love.window.fromPixels( px, py )
Arguments
number px
- The x-axis value of a coordinate in pixels.
number py
- The y-axis value of a coordinate in pixels.
Returns
number x
- The converted x-axis value of the coordinate, in density-independent units.
number y
- The converted y-axis value of the coordinate, in density-independent units.
Notes
The units of love.graphics.getWidth, love.graphics.getHeight, love.mouse.getPosition, mouse events, love.touch.getPosition, and touch events are always in terms of pixels.
See Also
Other Languages
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info