Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
How to know if i'm pressing in the alpha channel of a sprite — Gideros Forum

How to know if i'm pressing in the alpha channel of a sprite

KrakatoaKrakatoa Member
edited March 2014 in Game & application design
I have rounded buttons with irregular areas.

¿How can I check if i'm pressing in the alpha channel to discard the click?

This is my code:

StartMenu = Core.class(Sprite)
local logo_background = Bitmap.new(Texture.new("background.png"))
local start_button = Bitmap.new(Texture.new("SM_start.png"))

function StartMenu:init()
logo_background:setScale(0.96, 1.04)
self:addChild(logo_background)
self:addChild(start_button)
start_button:addEventListener(Event.MOUSE_DOWN, self.startGame, self)
end

function StartMenu:startGame(event)
if start_button:hitTestPoint(event.x, event.y) then
start_button.isFocus = true
end
end


Inside the startGame i want to check if the click is in the alpha zone to discard it.
I think one way is to access to the pixel clicked but I don't how to acces to that info.

Comments

Sign In or Register to comment.