Hi guys!
I have black overlay to prevent buttons underneath it being clicked.
Why it doesn't stop event.touch propagation? It detects touches, but they propagate further below.
--BlackOverlay.lua:
BlackOverlay=Core.class(Sprite)
function BlackOverlay:init(overlayColor)
local color=overlayColor or 0
self.pixel=Pixel.new(color,1,720,1280); --self.pixel:setAlpha(0)
self:addChild(self.pixel)
self:addEventListener(Event.TOUCHES_END, function(event)
if self.pixel:hitTestPoint(event.touch.x,event.touch.y) then event:stopPropagation(); print"touched pixel" end
end)
end |
--Main.lua:
sceneManager = SceneManager.new({
["scene1"] = scene1,
["scene2"] = scene2,
["scene3"] = scene3,
["scene4"] = scene4,
["scene5"] = scene5,
})
stage:addChild(sceneManager)
sceneManager:changeScene("scene1")
BLACKOVERLAY=BlackOverlay.new()
stage:addChild(BLACKOVERLAY) |
Comments
переконайся що вище спрайту нічого немає
також додай подію нажаття(click down) і там теж пропиши event:stopPropagation
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
коли дадаєш оверлей вмикай змінну, коли прибираєш вимикай
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
Here: https://github.com/ar2rsawseen/GiderosCodingEasy/blob/master/GiderosCodingEasy.lua
Likes: Apollo14
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
Likes: pie, Apollo14
Likes: Apollo14
Maybe try something like this (not tested)...
Likes: pie, Apollo14
Imho besides 'Sprite:ignoreTouches()' it could be great to have 'Sprite:destroy()' call (remove all children, and children of children, with whatever listeners and timers they have)
Is it a good thing or it may cause problems somewhere?
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
Likes: Apollo14