Revision as of 02:20, 24 December 2020 by MoKaLux (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Supported platforms: Platform android.pngPlatform ios.pngPlatform mac.pngPlatform pc.pngPlatform html5.pngPlatform winrt.pngPlatform win32.png
Available since: Gideros 2016.04
Inherits from: Sprite


A Viewport sprite allows to display another view of a tree hierarchy already on stage. Sprites can't have two parents, but thanks to Viewport you can display the same Sprite twice on the stage.

Useful for split screen games, mini maps and so on.


Displaying same Bitmap in multiple views

-- content we want to display in multiple views
local content ="ball.png"))

-- now setup view 1 as a 300x300 window
-- add some transformations, just to see the difference
view1:setTransform(, -1.0000001192093, 1.0000001192093, 1.7320507764816, 50, 50))
-- add view to stage

-- now setup view 2 as a 200x200 window
view2:setPosition(0,300) -- lower down the screen
-- add some transformations, just to see the difference
view2:setTransform(, -0.38302224874496, 0.38302224874496, 0.32139378786087, 30, 30))
-- add view to stage

Methods creates a new viewport
Viewport:lookAngles sets up the viewport look angle transform matrix (eye position, pitch, yaw and roll angles)
Viewport:lookAt sets up the viewport look at transform matrix (eye, target position and up direction)
Viewport:setClip sets the viewport size
Viewport:setContent sets the viewport content (sprite)
Viewport:setProjection specifies a projection matrix to use when displaying the content
Viewport:setTransform sets the content transform matrix before it being displayed