phaser3學習筆記:camera

#### camera文檔描述

The Camera Manager is a plugin that belongs to a Scene and is
responsible for managing all of the Scene Cameras.

By default you can access the Camera Manager from within a Scene using
this.cameras, although this can be changed in your game config.

Create new Cameras using the add method. Or extend the Camera class
with your own addition code and then add the new Camera in using the
addExisting method.

Cameras provide a view into your game world, and can be positioned,
rotated, zoomed and scrolled accordingly.

A Camera consists of two elements: The viewport and the scroll values.

The viewport is the physical position and size of the Camera within
your game. Cameras, by default, are created the same size as your
game, but their position and size can be set to anything. This means
if you wanted to create a camera that was 320x200 in size, positioned
in the bottom-right corner of your game, you’d adjust the viewport to
do that (using methods like setViewport and setSize).

If you wish to change where the Camera is looking in your game, then
you scroll it. You can do this via the properties scrollX and scrollY
or the method setScroll. Scrolling has no impact on the viewport, and
changing the viewport has no impact on the scrolling.

By default a Camera will render all Game Objects it can see. You can
change this using the ignore method, allowing you to filter Game
Objects out on a per-Camera basis. The Camera Manager can manage up to
31 unique ‘Game Object ignore capable’ Cameras. Any Cameras beyond 31
that you create will all be given a Camera ID of zero, meaning that
they cannot be used for Game Object exclusion. This means if you need
your Camera to ignore Game Objects, make sure it’s one of the first 31
created.

A Camera also has built-in special effects including Fade, Flash,
Camera Shake, Pan and Zoom.

機器翻譯結果:

有道機器翻譯,大致參考一下

相機管理器是一個屬於場景的插件,負責管理所有的場景相機。
默認情況下,你可以在場景中使用這個來訪問相機管理器。相機,儘管這可以在你的遊戲配置中改變。
使用添加方法創建新相機。或者使用您自己的添加代碼擴展Camera類,然後使用addExisting方法添加新相機。
攝像機提供了進入遊戲世界的視角,並且可以進行定位、旋轉、縮放和滾動。 攝像機由兩個元素組成:視口和滾動值。
視口是遊戲中攝像機的物理位置和大小。默認情況下,攝像頭的大小與你的遊戲相同,但它們的位置和大小可以設置爲任何值。這意味着如果你想要創建一個尺寸爲320x200的相機,並將其放置在遊戲的右下角,你便需要調整viewport去做到這一點(使用setViewport和setSize等方法)。
如果你想要改變攝像頭在遊戲中的位置,你可以滾動它。您可以通過屬性scrollX和scrollY或方法setScroll來實現這一點。滾動對視口沒有影響,改變視口對滾動也沒有影響。
默認情況下,攝像機會渲染它能看到的所有遊戲對象。你可以使用忽略方法來改變這一點,允許你在每個攝像頭的基礎上過濾遊戲對象。相機管理器可以管理多達31個獨特的“遊戲對象忽略能力”相機。你創建的任何超過31的相機都將被賦予0的相機ID,這意味着它們不能用於遊戲對象排除。這意味着如果你需要你的相機忽略遊戲對象,確保它是前31個創建的對象之一。
相機也有內置的特殊效果,包括褪色,閃光,相機抖動,平移和變焦。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章