Hi,
I just encountered something which may be a bug, but I am not sure.
I need to change the alpha property of an image using a slider control.
I have tried several different things, all of which work on the simulator, none of which will work on the iphone device.
I have had it so the alpha changes in realtime as the slider moves, so that it changes instantly when the touch event ends, and also as a transition when the touch event ends.
Here is some sample code of what I am trying to do.
If someone can help, I would appreciate, unless perhaps I indeed have found a bug, in which case hopefully it can be fixed.
– Begin Code
centerX = display.stageWidth * 0.5
local function dragSlide(event)
local stage = display.getCurrentStage()
local img2 = stage[2]
local slide = event.target
local phase = event.phase
if phase == “moved” then
if event.x >= 40 and event.x <= 280 then
slide.x = event.x
end
elseif phase == “ended” then
local picAlpha = (slide.x - 40) * 0.004167
if picAlpha > 1.0 then
picAlpha = 1.0
elseif picAlpha < 0.0 then
picAlpha = 0.0
end
–img2.alpha = picAlpha
transition.to(img2, {time=1000, alpha=picAlpha})
end
return true
end
local img1 = display.newImage(“img1.jpg”, 0, 0)
local img2 = display.newImage(“img2.jpg”, 0, 0)
img2.alpha = 0.5
local slide = display.newRect(0, 0, 20, 40)
slide:setFillColor(255, 255, 255)
slide.x = centerX
slide.y = 440
slide:addEventListener(“touch”, dragSlide)
– End Code
Thanks,
Dave [import]uid: 3948 topic_id: 411 reply_id: 300411[/import]