Difference between revisions of "Viewport"

From GiderosMobile
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
 +
<!-- GIDEROSOBJ:Viewport -->
 
'''<translate>Supported platforms</translate>:''' <br/>
 
'''<translate>Supported platforms</translate>:''' <br/>
 
'''<translate>Available since</translate>:''' Gideros 2016.04<br/>
 
'''<translate>Available since</translate>:''' Gideros 2016.04<br/>
Line 36: Line 37:
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
 
=== <translate>Methods</translate> ===
 
=== <translate>Methods</translate> ===
[[Special:MyLanguage/Viewport:lookAngles|Viewport:lookAngles]] <br/>
+
[[Special:MyLanguage/Viewport:lookAngles|Viewport:lookAngles]] <br/><!-- GIDEROSMTD:Viewport:lookAngles -->
[[Special:MyLanguage/Viewport:lookAt|Viewport:lookAt]] <br/>
+
[[Special:MyLanguage/Viewport:lookAt|Viewport:lookAt]] <br/><!-- GIDEROSMTD:Viewport:lookAt -->
[[Special:MyLanguage/Viewport:setContent|Viewport:setContent]] <br/>
+
[[Special:MyLanguage/Viewport:setContent|Viewport:setContent]] <br/><!-- GIDEROSMTD:Viewport:setContent -->
[[Special:MyLanguage/Viewport:setProjection|Viewport:setProjection]] ''<translate>Specify a projection matrix to use when displaying the content. </translate>''<br/>
+
[[Special:MyLanguage/Viewport:setProjection|Viewport:setProjection]] ''<translate>Specify a projection matrix to use when displaying the content. </translate>''<br/><!-- GIDEROSMTD:Viewport:setProjection -->
[[Special:MyLanguage/Viewport:setTransform|Viewport:setTransform]] <br/>
+
[[Special:MyLanguage/Viewport:setTransform|Viewport:setTransform]] <br/><!-- GIDEROSMTD:Viewport:setTransform -->
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
 
=== <translate>Events</translate> ===
 
=== <translate>Events</translate> ===
 
=== <translate>Constants</translate> ===
 
=== <translate>Constants</translate> ===
 
|}
 
|}

Revision as of 14:56, 31 August 2018

Supported platforms:
Available since: Gideros 2016.04
Inherits from: Sprite

Description

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.

Examples

Displaying same Bitmap in multiple views

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

-- now setup view 1 as a 300x300 window
view1=Viewport.new()
view1:setClip(0,0,300,300)
view1:setContent(content)

-- add some transformations, just to see the difference
view1:setTransform(Matrix.new(1.7320507764816, -1.0000001192093, 1.0000001192093, 1.7320507764816, 50, 50))

-- add view to stage
stage:addChild(view1)


-- now setup view 2 as a 200x200 window
view2=Viewport.new()
view2:setClip(0,0,200,200)
view2:setPosition(0,300) -- lower down the screen
view2:setContent(content)

-- add some transformations, just to see the difference
view2:setTransform(Matrix.new(0.32139378786087, -0.38302224874496, 0.38302224874496, 0.32139378786087, 30, 30))

-- add view to stage
stage:addChild(view2)

Methods

Viewport:lookAngles
Viewport:lookAt
Viewport:setContent
Viewport:setProjection Specify a projection matrix to use when displaying the content.
Viewport:setTransform

Events

Constants