Difference between revisions of "Sprite:setBlendMode"
From GiderosMobile
(remove language stuff) |
|||
Line 43: | Line 43: | ||
'''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/> | '''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/> | '''dst''': (String) destination blend mode '''optional'''<br/> | ||
+ | |||
+ | === Example === | ||
+ | <source lang="lua"> | ||
+ | for x = 1, 11 do | ||
+ | for y = 1, 11 do | ||
+ | local top = Pixel.new(topTex, s, s) | ||
+ | local btm = Pixel.new(btmTex, s, s) | ||
+ | stage:addChild(btm) | ||
+ | btm:addChild(top) | ||
+ | btm:setBlendMode(x, y) | ||
+ | btm:setPosition(lh + s * (x-1), lh + s * (y-1)) | ||
+ | end | ||
+ | end | ||
+ | </source> | ||
{{Sprite}} | {{Sprite}} |
Revision as of 21:39, 8 March 2023
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
Example
for x = 1, 11 do
for y = 1, 11 do
local top = Pixel.new(topTex, s, s)
local btm = Pixel.new(btmTex, s, s)
stage:addChild(btm)
btm:addChild(top)
btm:setBlendMode(x, y)
btm:setPosition(lh + s * (x-1), lh + s * (y-1))
end
end
- Sprite:addChild
- Sprite:addChildAt
- Sprite:clearBlendMode
- Sprite:clone
- Sprite:contains
- Sprite:get
- Sprite:getAlpha
- Sprite:getAnchorPoint
- Sprite:getAnchorPosition
- Sprite:getBounds
- Sprite:getChildAt
- Sprite:getChildIndex
- Sprite:getChildrenAtPoint
- Sprite:getClip
- Sprite:getColorTransform
- Sprite:getDrawCount
- Sprite:getHeight
- Sprite:getLayoutConstraints
- Sprite:getLayoutInfo
- Sprite:getLayoutParameters
- Sprite:getMatrix
- Sprite:getNumChildren
- Sprite:getParent
- Sprite:getPosition
- Sprite:getRotation
- Sprite:getRotationX
- Sprite:getRotationY
- Sprite:getScale
- Sprite:getScaleX
- Sprite:getScaleY
- Sprite:getScaleZ
- Sprite:getSize
- Sprite:getSkew
- Sprite:getSkewX
- Sprite:getSkewY
- Sprite:getWidth
- Sprite:getX
- Sprite:getY
- Sprite:getZ
- Sprite:globalToLocal
- Sprite:hitTestPoint
- Sprite:isVisible
- Sprite:localToGlobal
- Sprite:redrawEffects
- Sprite:removeChild
- Sprite:removeChildAt
- Sprite:removeFromParent
- Sprite:set
- Sprite:setAlpha
- Sprite:setAnchorPoint
- Sprite:setAnchorPosition
- Sprite:setBlendMode
- Sprite:setClip
- Sprite:setColorTransform
- Sprite:setEffectConstant
- Sprite:setEffectStack
- Sprite:setGhosts
- Sprite:setLayoutConstraints
- Sprite:setLayoutParameters
- Sprite:setMatrix
- Sprite:setPosition
- Sprite:setRotation
- Sprite:setRotationX
- Sprite:setRotationY
- Sprite:setScale
- Sprite:setScaleX
- Sprite:setScaleY
- Sprite:setScaleZ
- Sprite:setShader
- Sprite:setShaderConstant
- Sprite:setSkew
- Sprite:setSkewX
- Sprite:setSkewY
- Sprite:setStencilOperation
- Sprite:setStopEventPropagation
- Sprite:setVisible
- Sprite:setX
- Sprite:setY
- Sprite:setZ
- Sprite:spriteToLocal
- Sprite:swapChildren
- Sprite:swapChildrenAt
- Sprite.ADD
- Sprite.ALPHA
- Sprite.EFFECT MODE AUTOMATIC
- Sprite.EFFECT MODE CONTINUOUS
- Sprite.EFFECT MODE TRIGGERED
- Sprite.LAYOUT ANCHOR CENTER
- Sprite.LAYOUT ANCHOR EAST
- Sprite.LAYOUT ANCHOR NORTH
- Sprite.LAYOUT ANCHOR NORTHEAST
- Sprite.LAYOUT ANCHOR NORTHWEST
- Sprite.LAYOUT ANCHOR SOUTH
- Sprite.LAYOUT ANCHOR SOUTHEAST
- Sprite.LAYOUT ANCHOR SOUTHWEST
- Sprite.LAYOUT ANCHOR WEST
- Sprite.LAYOUT FILL BOTH
- Sprite.LAYOUT FILL HORIZONTAL
- Sprite.LAYOUT FILL NONE
- Sprite.LAYOUT FILL VERTICAL
- Sprite.MULTIPLY
- Sprite.NO ALPHA
- Sprite.SCREEN
- Sprite.new
- Event.ADDED_TO_STAGE
- Event.ENTER_FRAME
- Event.KEY_CHAR
- Event.KEY_DOWN
- Event.KEY_UP
- Event.LAYOUT_RESIZED
- Event.MOUSE_DOWN
- Event.MOUSE_ENTER
- Event.MOUSE_HOVER
- Event.MOUSE_LEAVE
- Event.MOUSE_MOVE
- Event.MOUSE_UP
- Event.MOUSE_WHEEL
- Event.REMOVED_FROM_STAGE
- Event.TOUCHES_BEGIN
- Event.TOUCHES_CANCEL
- Event.TOUCHES_END
- Event.TOUCHES_MOVE