OK, I lied I’ll answer the second question too.
First, SSK2 has this feature in it, but the concept you’re describing is what I think of as ‘in bounds’. Specifically, in bounds of an objec’ts axis-aligned bounding box:
local function isInBounds( obj, obj2 ) if(not obj2) then return false end local bounds = obj2.contentBounds if( obj.x \> bounds.xMax ) then return false end if( obj.x \< bounds.xMin ) then return false end if( obj.y \> bounds.yMax ) then return false end if( obj.y \< bounds.yMin ) then return false end return true end
With the above code, you can extend my original example as follows:
local function onTouch( self, event ) local phase = event.phase if( phase == "began" ) then self.isFocus = true display.currentStage:setFocus( event.target, event.id ) -- SET OBJECT TO GREEN FILL self:setFillColor(0,1,0) elseif( self.isFocus ) then -- Touch in bounds? local inBounds = isInBounds( event, self ) if( phase == "moved" ) then -- Highlight as green it touch in bounds else clear to white if(inBounds) then self:setFillColor(0,1,0) else self:setFillColor(1,1,1) end elseif( phase == "ended" or phase == "cancelled" ) then self.isFocus = false display.currentStage:setFocus( event.target, nil ) -- Clear to white, touch is done self:setFillColor(1,1,1) end end return false end