You’d need to put the invisible rect at the bottom of the display group, that way you can still detect the other images/objects.
If you have the rect on top of everything else, and it is returning true for touches, then you’ll only detect the rect.
I.W.
if you have something like this:
mainDisplayGroup:insert( imageA )
mainDisplayGroup:insert( imageB )
mainDisplayGroup:insert( invisibleRect )
imageA would be at the bottom of the group and the invisibleRect would be at the top - if it covers the whole screen and is returning true for touch events, it would be the only object that would receive touch events.
It’s generally a good to add your objects in sequence near the bottom of your code.
For example I have this in my code:
--============================================================================== ------------------------------------------------------------------------------- levelGroup:insert( transRect ) --1st object added to my display group levelGroup:insert( LeftStick ) --2nd object added, but it is placed Above transRect levelGroup:insert( PTMBtn ) --3rd object added, a button, and is above the joystick levelGroup:insert( Pcross ) -- etc... etc... levelGroup:insert( JStext ) levelGroup:insert( PTtext ) levelGroup:insert( UTtext ) levelGroup:insert( TXtext ) levelGroup:insert( TYtext ) levelGroup:insert( WMbgi ) levelGroup:insert( pHUD ) levelGroup:insert( pauseBtn ) levelGroup:insert( PopupMenugroup ) levelGroup:insert( transRect ) --[[^^ this ^^ if I added my transRect at the end like this, it would be at the top of the display-group and since it covers the whole screen and has 'return true' in its function, then I would not be able to touch my other objects - joystick, buttons etc.. - because they would technically be behind my invisible rectangle. --]] Just remember that it's backwards to what you might think: group:insert( object1 ) -- Bottom of display-group group:insert( object2 ) -- Above object1 group:insert( object3 ) -- Above object1 and object2
Now you can also see I have my ‘LeftStick’ (just a joystick) being added to the my level display-group After the transRect. You might think that since the transRect was added first that it would be at the “top layer”, but actually it is at the bottom.
If I did this:
levelGroup:insert( LeftStick )
levelGroup:insert( transRect )
LeftStick is now at the bottom and since my invisible rectangle covers the entire display and returns true in its touch function, then I would not be able to use my joystick because it is Behind my invisible rectangle.
Hope this helped.
-Saer
Edit: Again, all my touch-sensitive objects are added to the main display group *Above my transRect. Otherwise my transRect would be the only object receiving touch events because it covers the whole screen and is returning true.