Difference between revisions of "Texture"

From GiderosMobile
 
(12 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
 
<languages />
 
 
 
<!-- GIDEROSOBJ:Texture -->
 
<!-- GIDEROSOBJ:Texture -->
 +
'''Supported platforms:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]]<br/>
 +
'''Available since:''' Gideros 2011.6<br/>
 +
'''Inherits from:''' [[TextureBase]]<br/>
  
'''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]]
+
=== Description ===
<br/>
+
The '''Texture''' class lets you work with textures in an application. The Texture class lets you create a new Texture object to load from an image file and display in scene tree.
 
 
'''<translate>Available since</translate>:''' Gideros 2011.6
 
<br/>
 
  
'''<translate>Inherits from</translate>:''' [[Special:MyLanguage/TextureBase|TextureBase]]
+
=== Example ===
<br/>
+
<syntaxhighlight lang="lua">
 
 
=== <translate>Description</translate> ===
 
<translate>
 
The [[Special:MyLanguage/Texture|Texture]] class lets you work with textures in an application. The [[Special:MyLanguage/Texture|Texture]] class lets you create a new [[Special:MyLanguage/Texture|Texture]] object to load from an image file and display in scene tree.
 
<br/>
 
</translate>
 
 
 
=== <translate>Example</translate> ===
 
<source lang="lua">
 
 
-- TEXTURE REPEAT
 
-- TEXTURE REPEAT
 
wall = Shape.new()
 
wall = Shape.new()
local texture = Texture.new("gfx/enemy01.png", true, {wrap = Texture.REPEAT}) -- put your image.png
+
local texture = Texture.new("gfx/enemy01.png", true, {wrap = TextureBase.REPEAT}) -- put your image.png
 
wall:setFillStyle(Shape.TEXTURE, texture)
 
wall:setFillStyle(Shape.TEXTURE, texture)
 
wall:beginPath()
 
wall:beginPath()
Line 36: Line 24:
 
wall:setPosition(128, 128)
 
wall:setPosition(128, 128)
 
stage:addChild(wall)
 
stage:addChild(wall)
</source>
+
</syntaxhighlight>
 
 
  
 
{|-
 
{|-
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
=== <translate>Methods</translate> ===
+
=== Methods ===
[[Special:MyLanguage/Texture.new|Texture.new]] ''<translate>creates a new Texture object</translate>''
+
[[Texture.loadAsync]] ''asynchronously loads a texture from a file''<br/><!--GIDEROSMTD:Texture.loadAsync(callback,filename,filtering,options) asynchronously loads a texture from a file-->
<br/>
+
[[Texture.new]] ''creates a new Texture object from a file''<br/><!--GIDEROSMTD:Texture.new(filename,filtering,options) creates a new Texture object from a file-->
<!-- GIDEROSMTD:Texture.new(filename,filtering,options) creates a new Texture object -->
+
[[Texture.new]] ''creates a new Texture object from a pixel array''<br/><!--GIDEROSMTD:Texture.new(pixels,width,height,filtering,options) creates a new Texture object from a pixel array-->
[[Special:MyLanguage/Texture.new|Texture.new]]
 
<br/>
 
<!-- GIDEROSMTD:Texture.new(pixels,width,height,filtering,options) -->
 
  
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
=== <translate>Events</translate> ===
+
 
=== <translate>Constants</translate> ===
+
=== Events ===
 +
=== Constants ===
 
|}
 
|}
  
{{Texture}}
+
{{GIDEROS IMPORTANT LINKS}}

Latest revision as of 14:34, 20 July 2024

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

Description

The Texture class lets you work with textures in an application. The Texture class lets you create a new Texture object to load from an image file and display in scene tree.

Example

-- TEXTURE REPEAT
wall = Shape.new()
local texture = Texture.new("gfx/enemy01.png", true, {wrap = TextureBase.REPEAT}) -- put your image.png
wall:setFillStyle(Shape.TEXTURE, texture)
wall:beginPath()
wall:moveTo(0,0)
wall:lineTo(150, 0)
wall:lineTo(150, 150)
wall:lineTo(0, 150)
wall:closePath()
wall:endPath()
wall:setAnchorPoint(0.5, 0.5)
wall:setPosition(128, 128)
stage:addChild(wall)

Methods

Texture.loadAsync asynchronously loads a texture from a file
Texture.new creates a new Texture object from a file
Texture.new creates a new Texture object from a pixel array

Events

Constants