Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
viewport:hitTestPoint - Gideros Forum

viewport:hitTestPoint

I am trying to use hitTestPoint on a ViewPort, but it's not behaving as expected. Viewports don't seem to have width and height. What am I doing wrong? (I could manually add an invisible pixel to use hitTestPoint, but maybe I don't have to?
print ("Viewport Test")
local pixel = Pixel.new(0,1,105,107)
pixel:setPosition(51,61)
stage:addChild(pixel)
print("Pixel", pixel:getX(), pixel:getY(), "-", pixel:getWidth(), pixel:getHeight(), "-", pixel:getBounds(stage))
print(pixel:hitTestPoint(110, 110))
 
local bg = Pixel.new(0xFFAABB,0.5,200,200)
bg:setPosition(212,211)
stage:addChild(bg)
print(bg:getBounds(bg))
print("Background", bg:getX(), bg:getY(), "-", bg:getWidth(), bg:getHeight(), "-", bg:getBounds(stage))
print(bg:hitTestPoint(220, 222))
 
local vp = Viewport.new()
vp:setClip(0,0,100,100)
vp:setContent(pixel)
vp:setPosition(212, 211)
stage:addChild(vp)
print("Viewport", vp:getX(), vp:getY(), "-", vp:getWidth(), vp:getHeight(), "-", vp:getBounds(stage))
print(vp:hitTestPoint(220, 222))
Generates
Viewport Test
Pixel	51	61	-	105	107	-	51	61	105	107
true
0	0	200	200
Background	212	211	-	200	200	-	212	211	200	200
true
Viewport	212	211	-	0	0	-	0	0	0	0
false

image.png
242 x 231 - 2K

Comments

Sign In or Register to comment.