Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
EASY: setVisible function? — Gideros Forum

EASY: setVisible function?

edited November 2012 in General questions
I try to set my sprite:setVisible(false) but the object still receive hit when clicking on its location. How can we inactive that sprite?

Currently my work around is instead of invisible/inactive it, I set its position out of screen >"<

Comments

  • ar2rsawseenar2rsawseen Maintainer
    Accepted Answer
    Well there are many options, that could work based on what you need to do with object.
    You may (as you did) position obejct of the screen, or
    set scale to 0 or
    remove object from parent and than add it back when you need it
  • how about this?
    if sprite:isVisible() then
    	-- some action
    end
  • edited November 2012
    @ar2rsawseen: thank, that's complicated but seem we have no way
    @zaniar: you misunderstood my problem :) For example after I hide an object, I want to inactive that object too (like in Corona SDK) but it's still there and still fire event onclick (just only invisible)

  • @zaniar: you misunderstood my problem :) For example after I hide an object, I want to inactive that object too (like in Corona SDK) but it's still there and still fire event onclick (just only invisible)
    i think he is trying to suggest something like this,
    local function onMouseDown(self, event)
    	if self:hitTestPoint(event.x, event.y) then
    		if self:isVisible() then
    	                 -- some action
                     end
    	end
    end
    :)

    Likes: zaniar

    +1 -1 (+1 / -0 )Share on Facebook
  • MellsMells Guru
    edited November 2012
    Which version would you say is the most efficient one?
    local function onMouseDown(self, event)
        if self:hitTestPoint(event.x, event.y) then
    	if self:isVisible() then
    	           -- some action
            end
        end
    end
    or
    local function onMouseDown(self, event)
        if self:hitTestPoint(event.x, event.y) then
                if not(self:isVisible()) then
    	            return
                end
                -- some action
        end
    end
    twitter@TheWindApps Artful applications : The Wind Forest. #art #japan #apps
  • i think so first one as that will chk the visibility for only those objects who are touched

    :)
  • @hgvyas123
    I have edited my sample just as you were posting because it was taken from a project with other requirements so it's possible your comment refers to the previous version now.
    twitter@TheWindApps Artful applications : The Wind Forest. #art #japan #apps
  • NP :)

    now i dont think so there is any difference in perfomance or efficiency between this two func

    might be logically

    if self:isVisible() then
    -- some action
    end

    is faster than

    if not(self:isVisible()) then
    return
    end
    -- some action

    but that diff can be ignored totally especially for 2-3 objects [ how many objects we can except which are touched at the same time]

    :)
Sign In or Register to comment.