Difference between revisions of "Sprite:setBlendMode"

From GiderosMobile
(remove language stuff)
(10 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
 
'''Available since:''' Gideros 2011.6<br/>
 
'''Available since:''' Gideros 2011.6<br/>
 +
'''Class:''' [[Sprite]]<br/>
 +
 
=== Description ===
 
=== Description ===
<br />
+
Sets the blend mode of the sprite.
Sets the blend mode of the sprite. This method can be called with 1 or 2 parameters.
 
If one parameter is passed it must be one of the following blending modes:<br />
 
<br />
 
<ul><br />
 
<li>Sprite.ALPHA = "alpha"</li><br />
 
<li>Sprite.NO_ALPHA = "noAlpha"</li><br />
 
<li>Sprite.ADD = "add"</li><br />
 
<li>Sprite.MULTIPLY = "multiply"</li><br />
 
<li>Sprite.SCREEN = "screen"</li><br />
 
</ul><br />
 
<br />
 
If a `Sprite` object doesn't set any blending mode, it takes the blending mode from its parent sprite.<br />
 
<br />
 
<ul><br />
 
<li>*Note:** The following two lines are completely same:</li><br />
 
</ul><br />
 
<pre><code><br />
 
sprite:setBlendMode("add")<br />
 
sprite:setBlendMode(Sprite.ADD)<br />
 
</code></pre><br />
 
It's a matter of taste which one to choose.<br />
 
<br />
 
<br />
 
If two parameters are passed to this method, then a source and destination blend can be set (in that order) and each take the values:
 
<br />
 
<ul><br />
 
<li>Sprite.ZERO = "zero"</li><br />
 
<li>Sprite.ONE = "one"</li><br />
 
<li>Sprite.SRC_COLOR = "srcColor"</li><br />
 
<li>Sprite.ONE_MINUS_SRC_COLOR = "oneMinusSrcColor"</li><br />
 
<li>Sprite.DST_COLOR = "dstColor"</li><br />
 
<li>Sprite.ONE_MINUS_DST_COLOR = "oneMinusDstColor"</li><br />
 
<li>Sprite.SRC_ALPHA = "srcAlpha"</li><br />
 
<li>Sprite.ONE_MINUS_SRC_ALPHA = "oneMinusSrcAlpha"</li><br />
 
<li>Sprite.DST_ALPHA = "dstAlpha"</li><br />
 
<li>Sprite.ONE_MINUS_DST_ALPHA = "oneMinusDstAlpha"</li><br />
 
<li>Sprite.SRC_ALPHA_SATURATE = "srcAlphaSaturate"</li><br />
 
</ul><br />
 
 
<source lang="lua">
 
<source lang="lua">
Sprite:setBlendMode(blendMode or src,dst)
+
Sprite:setBlendMode(blendMode or src,dst)
 
</source>
 
</source>
'''blendMode or src''': (String) If one parameter is used, this is the blend mode. If two parameters are used this is the source blend specification. ''''''<br/>
+
 
'''dst''': (string) Destination blend mode '''optional'''<br/>
+
This method can be called with 1 or 2 parameters.
 +
 
 +
If one parameter is passed it must be one of the following blending modes:
 +
*Sprite.ALPHA = "alpha"
 +
*Sprite.NO_ALPHA = "noAlpha"
 +
*Sprite.ADD = "add"
 +
*Sprite.MULTIPLY = "multiply"
 +
*Sprite.SCREEN = "screen"
 +
If a '''Sprite''' object doesn't set any blending mode, it takes the blending mode from its parent sprite.
 +
 
 +
'''Note''': the following two lines are completely the same:
 +
<source lang="lua">
 +
sprite:setBlendMode("add")
 +
sprite:setBlendMode(Sprite.ADD)
 +
</source>
 +
It's a matter of taste which one to choose.
 +
 
 +
 
 +
If two parameters are passed to this method, then a source and destination blend can be set (in that order) and each takes the values:
 +
*Sprite.ZERO = "zero"
 +
*Sprite.ONE = "one"
 +
*Sprite.SRC_COLOR = "srcColor"
 +
*Sprite.ONE_MINUS_SRC_COLOR = "oneMinusSrcColor"
 +
*Sprite.DST_COLOR = "dstColor"
 +
*Sprite.ONE_MINUS_DST_COLOR = "oneMinusDstColor"
 +
*Sprite.SRC_ALPHA = "srcAlpha"
 +
*Sprite.ONE_MINUS_SRC_ALPHA = "oneMinusSrcAlpha"
 +
*Sprite.DST_ALPHA = "dstAlpha"
 +
*Sprite.ONE_MINUS_DST_ALPHA = "oneMinusDstAlpha"
 +
*Sprite.SRC_ALPHA_SATURATE = "srcAlphaSaturate"
 +
 
 +
=== Parameters ===
 +
'''blendMode or src''': (String) if one parameter is used, this is the blend mode. If two parameters are used this is the source blend specification<br/>
 +
'''dst''': (String) destination blend mode '''optional'''<br/>
 +
 
 +
{{Sprite}}

Revision as of 03:53, 3 February 2021

Available since: Gideros 2011.6
Class: Sprite

Description

Sets the blend mode of the sprite.

Sprite:setBlendMode(blendMode or src,dst)

This method can be called with 1 or 2 parameters.

If one parameter is passed it must be one of the following blending modes:

  • Sprite.ALPHA = "alpha"
  • Sprite.NO_ALPHA = "noAlpha"
  • Sprite.ADD = "add"
  • Sprite.MULTIPLY = "multiply"
  • Sprite.SCREEN = "screen"

If a Sprite object doesn't set any blending mode, it takes the blending mode from its parent sprite.

Note: the following two lines are completely the same:

sprite:setBlendMode("add")
sprite:setBlendMode(Sprite.ADD)

It's a matter of taste which one to choose.


If two parameters are passed to this method, then a source and destination blend can be set (in that order) and each takes the values:

  • Sprite.ZERO = "zero"
  • Sprite.ONE = "one"
  • Sprite.SRC_COLOR = "srcColor"
  • Sprite.ONE_MINUS_SRC_COLOR = "oneMinusSrcColor"
  • Sprite.DST_COLOR = "dstColor"
  • Sprite.ONE_MINUS_DST_COLOR = "oneMinusDstColor"
  • Sprite.SRC_ALPHA = "srcAlpha"
  • Sprite.ONE_MINUS_SRC_ALPHA = "oneMinusSrcAlpha"
  • Sprite.DST_ALPHA = "dstAlpha"
  • Sprite.ONE_MINUS_DST_ALPHA = "oneMinusDstAlpha"
  • Sprite.SRC_ALPHA_SATURATE = "srcAlphaSaturate"

Parameters

blendMode or src: (String) if one parameter is used, this is the blend mode. If two parameters are used this is the source blend specification
dst: (String) destination blend mode optional