Documentation ¶
Overview ¶
Package kamera provides a camera object for Ebitengine v2.
Index ¶
- type Camera
- func (cam *Camera) ActualAngle() (angle float64)
- func (cam *Camera) AddTrauma(factor float64)
- func (cam *Camera) Angle() (angle float64)
- func (cam *Camera) ApplyCameraTransform(geoM *ebiten.GeoM)
- func (cam *Camera) ApplyCameraTransformToPoint(x, y float64) (float64, float64)
- func (cam *Camera) Bottom() float64
- func (cam *Camera) Center() (X float64, Y float64)
- func (cam *Camera) Draw(worldObject *ebiten.Image, worldObjectOps *ebiten.DrawImageOptions, ...)
- func (cam *Camera) DrawWithColorM(worldObject *ebiten.Image, cm colorm.ColorM, ...)
- func (cam *Camera) Height() float64
- func (cam *Camera) LookAt(targetX, targetY float64)
- func (cam *Camera) Reset()
- func (cam *Camera) Right() float64
- func (cam *Camera) ScreenToWorld(screenX, screenY int) (worldX float64, worldY float64)
- func (cam *Camera) SetAngle(angle float64)
- func (cam *Camera) SetSize(w, h float64)
- func (cam *Camera) SetTopLeft(x, y float64)
- func (cam *Camera) String() string
- func (cam *Camera) TopLeft() (X float64, Y float64)
- func (cam *Camera) Width() float64
- type ShakeOptions
- type SmoothOptions
- type SmoothType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Camera ¶
type Camera struct { // Top-left X position of camera TopLeftX float64 // Top-left Y position of camera TopLeftY float64 // ZoomFactor is the camera zoom (scaling) factor. Default is 1. ZoomFactor float64 // SmoothType is the camera movement smoothing type. SmoothType SmoothType // SmoothOptions holds the camera movement smoothing settings SmoothOptions *SmoothOptions // If ShakeEnabled is false, AddTrauma() has no effect and shake is always 0. // // The default value is false ShakeEnabled bool XAxisSmoothingDisabled bool YAxisSmoothingDisabled bool // ShakeOptions holds the camera shake options. ShakeOptions *ShakeOptions // contains filtered or unexported fields }
Camera object.
Use the `Camera.LookAt()` to align the center of the camera to the target.
func (*Camera) ActualAngle ¶ added in v2.6.0
ActualAngle returns camera rotation angle (including the angle of trauma shaking.).
The unit is radian.
func (*Camera) Angle ¶ added in v2.6.0
Angle returns camera rotation angle (The angle of trauma shake is not included.).
The unit is radian.
func (*Camera) ApplyCameraTransform ¶
func (cam *Camera) ApplyCameraTransform(geoM *ebiten.GeoM)
ApplyCameraTransform applies geometric transformation to given geoM
func (*Camera) ApplyCameraTransformToPoint ¶ added in v2.9.0
ApplyCameraTransformToPoint applies camera transformation to given point
func (*Camera) Bottom ¶ added in v2.95.1
Bottom returns the bottom edge position of the camera in world-space.
func (*Camera) Draw ¶
func (cam *Camera) Draw(worldObject *ebiten.Image, worldObjectOps *ebiten.DrawImageOptions, screen *ebiten.Image)
Draw applies the Camera's geometric transformation then draws the object on the screen with drawing options.
func (*Camera) DrawWithColorM ¶ added in v2.93.0
func (cam *Camera) DrawWithColorM(worldObject *ebiten.Image, cm colorm.ColorM, worldObjectOps *colorm.DrawImageOptions, screen *ebiten.Image)
DrawWithColorM applies the Camera's geometric transformation then draws the object on the screen with colorm package drawing options.
func (*Camera) LookAt ¶
LookAt aligns the midpoint of the camera viewport to the target.
Camera motion smoothing is only applied with this method. Use this function only once in Update() and change only the (targetX, targetY)
func (*Camera) Right ¶ added in v2.95.1
Right returns the right edge position of the camera in world-space.
func (*Camera) ScreenToWorld ¶
ScreenToWorld converts screen-space coordinates to world-space
func (*Camera) SetTopLeft ¶ added in v2.95.1
SetTopLeft sets top-left position of the camera in world-space.
Unlike the LookAt() method, the position is set directly without any smoothing.
Useful for static cameras.
type ShakeOptions ¶ added in v2.93.0
type ShakeOptions struct { // Noise generator for noise types and settings. Noise *fastnoise.State[float64] MaxX float64 // Maximum X-axis shake. 0 means disabled MaxY float64 // Maximum Y-axis shake. 0 means disabled MaxAngle float64 // Max shake angle (radians). 0 means disabled MaxZoomFactor float64 // Zoom factor strength [1-0]. 0 means disabled TimeScale float64 // Noise time domain speed Decay float64 // Decay for trauma }
func DefaultCameraShakeOptions ¶
func DefaultCameraShakeOptions() *ShakeOptions
type SmoothOptions ¶ added in v2.9.0
type SmoothOptions struct { // LerpSpeedX is the X-axis linear interpolation speed every frame. // Value is in the range [0-1]. Default value is 0.09 // // A smaller value will reach the target slower. LerpSpeedX float64 // LerpSpeedY is the Y-axis linear interpolation speed every frame. Value is in the range [0-1]. // // A smaller value will reach the target slower. LerpSpeedY float64 // SmoothDampTimeX is the X-Axis approximate time it will take to reach the target. // // A smaller value will reach the target faster. Default value is 0.2 SmoothDampTimeX float64 // SmoothDampTimeY is the Y-Axis approximate time it will take to reach the target. // // A smaller value will reach the target faster. Default value is 0.2 SmoothDampTimeY float64 // SmoothDampMaxSpeedX is the maximum speed the camera can move while smooth damping in X-Axis // // Default value is 1000 SmoothDampMaxSpeedX float64 // SmoothDampMaxSpeedY is the maximum speed the camera can move while smooth damping in Y-Axis // // Default value is 1000 SmoothDampMaxSpeedY float64 }
SmoothOptions is the camera movement smoothing options.
func DefaultSmoothOptions ¶ added in v2.9.0
func DefaultSmoothOptions() *SmoothOptions
type SmoothType ¶ added in v2.93.0
type SmoothType int
SmoothType is the camera movement smoothing type.
const ( // None is instant movement to the target. No smoothing. None SmoothType = iota // Lerp is Lerp() function. Lerp // SmoothDamp is SmoothDamp() function. SmoothDamp )