It looks like you're new here. If you want to get involved, click one of these buttons!
--Create the shape object local myMask = Shape.new() local LEFTB, RIGHTB local imageHolder = Sprite.new() --Let's make it visible by placing it on the stage stage:addChild(myMask) --Now load the texture (image that we want to mask) local matrix = Matrix.new(1, 0, 0, 1, 0, 0) local texture = Texture.new("types.png") local function onClick(but, event) local matrixy = matrix:getTx() if(but.name == "RIGHTB") then print(matrixy) matrixy = matrixy + 100 matrix:setTx(matrixy) end if(but.name == "LEFTB") then matrixy = matrixy - 100 matrix:setTx(matrixy) end end --Now let us draw the texture in the shape myMask:clear() myMask:setFillStyle(Shape.TEXTURE, texture, matrix) myMask:beginPath() myMask:moveTo(10,10) myMask:lineTo(110,10) myMask:lineTo(110,100) myMask:lineTo(10,100) myMask:lineTo(10,10) myMask:closePath() myMask:endPath() local options = Bitmap.new(Texture.new("bottomLeft.png") ) local optionsOver = Bitmap.new(Texture.new("bottomLeftOver.png") ) local options2 = Bitmap.new(Texture.new("bottomLeft.png") ) local optionsOver2 = Bitmap.new(Texture.new("bottomLeftOver.png") ) RIGHTB = Button.new(options2, optionsOver2, true, false, nil, "Ayarlar2", 20,35, nil, 0x666666) LEFTB = Button.new(options, optionsOver, true, false, nil, "Ayarlar3", 20,35, nil, 0x666666) --CENTERB = Button.new(options, optionsOver,false,false,nil,"Ayarlar", 20,35, nil, 0x666666 LEFTB:setPosition(15,475-LEFTB:getHeight()) RIGHTB:setPosition(795 - RIGHTB:getWidth(),475-RIGHTB:getHeight()) LEFTB.name = "LEFTB" RIGHTB.name = "RIGHTB" LEFTB:addEventListener("click", onClick, LEFTB) RIGHTB:addEventListener("click", onClick, RIGHTB) stage:addChild(LEFTB) stage:addChild(RIGHTB) |
Comments
You must redraw your shape
modify your onClick function to something like this:
GTween can tween any value. In your case, you can tween tx & ty value. You need to define getter & setter for tx & ty. Here is a little (untested) example:
tx and ty are not properties of myMask but the matrix object so I cant manipulate them this way..
GTween.new(myMask, duration,
{
tx = newTxValue,
ty = newTyValue
}
)
GTween.new(myMask, 1, {tx = matrixy}) outputs:
gtween.lua:387: Parameter 'param' must be one of the accepted values.
stack traceback:
Cheers both
Like fading 100 to 0 or not possible :P
Did you know that you can tween anything?
@Mells Don't know how did I miss that, that's uber awesome
@ar2rsawseen Well then I have to use some other way for the the thing I want.
No more bright ideas for a scroll bar where the middle image is at 100% alpha and it goes to %0 on sides. This is easy with a mask where center is %100 transparent while edges are %60 so it creates the illusion.
Else I have to manually do everything if no masking solution is avaible. Like making center sprite %100 transparenct and side ones %60
@twisttap I understand that you don't want to be stuck too long but as far as I can understand how things work (and I'm not an experimented dev) -> Parameter 'param' must be one of the accepted values. "should" be solved by the link I gave if implemented well.
If you need a solution then this will solve your problem. If you want to find an alternative quickly, it's great if @ar2rsawseen 's solution works for your needs.
Likes: ar2rsawseen, gorkem
thanks