Difference between revisions of "TextureRegion"

From GiderosMobile
Line 33: Line 33:
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
 
=== <translate>Methods</translate> ===
 
=== <translate>Methods</translate> ===
[[Special:MyLanguage/TextureRegion.new|TextureRegion.new]] ''<translate>creates a new TextureRegion object</translate>''<br/><!-- GIDEROSMTD:TextureRegion.new -->
+
[[Special:MyLanguage/TextureRegion.new|TextureRegion.new]] ''<translate>creates a new TextureRegion object</translate>''<br/><!-- GIDEROSMTD:TextureRegion.new(texture) creates a new TextureRegion object -->
[[Special:MyLanguage/TextureRegion.new|TextureRegion.new]] <br/><!-- GIDEROSMTD:TextureRegion.new -->
+
[[Special:MyLanguage/TextureRegion.new|TextureRegion.new]] <br/><!-- GIDEROSMTD:TextureRegion.new(texture,x,y,width,height)  -->
[[Special:MyLanguage/TextureRegion:getRegion|TextureRegion:getRegion]] ''<translate>returns the coordinates of the region</translate>''<br/><!-- GIDEROSMTD:TextureRegion:getRegion -->
+
[[Special:MyLanguage/TextureRegion:getRegion|TextureRegion:getRegion]] ''<translate>returns the coordinates of the region</translate>''<br/><!-- GIDEROSMTD:TextureRegion:getRegion(baseCoordiniates) returns the coordinates of the region -->
[[Special:MyLanguage/TextureRegion:getScale|TextureRegion:getScale]] ''<translate>returns the scale ratio of the underlying atlas</translate>''<br/><!-- GIDEROSMTD:TextureRegion:getScale -->
+
[[Special:MyLanguage/TextureRegion:getScale|TextureRegion:getScale]] ''<translate>returns the scale ratio of the underlying atlas</translate>''<br/><!-- GIDEROSMTD:TextureRegion:getScale() returns the scale ratio of the underlying atlas -->
[[Special:MyLanguage/TextureRegion:setRegion|TextureRegion:setRegion]] ''<translate>sets the coordinates of the region</translate>''<br/><!-- GIDEROSMTD:TextureRegion:setRegion -->
+
[[Special:MyLanguage/TextureRegion:setRegion|TextureRegion:setRegion]] ''<translate>sets the coordinates of the region</translate>''<br/><!-- GIDEROSMTD:TextureRegion:setRegion(x,y,width,height) sets the coordinates of the region -->
 
| 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 15:31, 13 September 2018


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

Description


The TextureRegion class specifies a texture and a rectangular region in it. It is used to define independent texture regions
within a texture atlas which is a large image, which contains many smaller sub-images.

Examples

Example

local texture = Texture.new(&quot;atlas.png&quot;)

-- define 4 equal regions of size 100x100 from &quot;atlas.png&quot;
local region1 = TextureRegion.new(texture, 0,   0,   100, 100)
local region2 = TextureRegion.new(texture, 100, 0,   100, 100)
local region3 = TextureRegion.new(texture, 100, 100, 100, 100)
local region4 = TextureRegion.new(texture, 0,   100, 100, 100)

-- add these regions to scene tree
local bitmap1 = Bitmap.new(region1)
local bitmap2 = Bitmap.new(region2)
local bitmap3 = Bitmap.new(region3)
local bitmap4 = Bitmap.new(region4)

stage:addChild(bitmap1)
stage:addChild(bitmap2)
stage:addChild(bitmap3)
stage:addChild(bitmap4)

Methods

TextureRegion.new creates a new TextureRegion object
TextureRegion.new
TextureRegion:getRegion returns the coordinates of the region
TextureRegion:getScale returns the scale ratio of the underlying atlas
TextureRegion:setRegion sets the coordinates of the region

Events

Constants