@@ -72,6 +72,8 @@ class GraphicsLibrary
72
72
73
73
public:
74
74
static int newMask ( lua_State *L );
75
+ static int newHitTestOnlyMask ( lua_State *L );
76
+ static int newHitTestOnlyMaskFromPaint ( lua_State *L );
75
77
static int newGradient ( lua_State *L );
76
78
static int newImageSheet ( lua_State *L );
77
79
static int defineEffect ( lua_State *L );
@@ -114,6 +116,8 @@ GraphicsLibrary::Open( lua_State *L )
114
116
const luaL_Reg kVTable [] =
115
117
{
116
118
{ " newMask" , newMask },
119
+ { " newHitTestOnlyMask" , newHitTestOnlyMask },
120
+ { " newHitTestOnlyMaskFromPaint" , newHitTestOnlyMaskFromPaint },
117
121
// { "newVertexArray", newVertexArray },
118
122
{ " newGradient" , newGradient },
119
123
{ " newImageSheet" , newImageSheet },
@@ -203,6 +207,43 @@ GraphicsLibrary::newMask( lua_State *L )
203
207
return result;
204
208
}
205
209
210
+ // graphics.newHitTestOnlyMask( filename [, baseDir] )
211
+ int
212
+ GraphicsLibrary::newHitTestOnlyMask ( lua_State *L )
213
+ {
214
+ int result = GraphicsLibrary::newMask ( L );
215
+
216
+ if ( result )
217
+ {
218
+ lua_getfield ( L, LUA_REGISTRYINDEX, BitmapMask::kHitTestOnlyTable );
219
+
220
+ if ( lua_istable ( L, -1 ) )
221
+ {
222
+ lua_pushvalue ( L, -2 );
223
+ lua_pushboolean ( L, 1 );
224
+ lua_rawset ( L, -3 );
225
+ lua_pop ( L, 1 );
226
+ }
227
+
228
+ else
229
+ {
230
+ result = 0 ;
231
+ }
232
+ }
233
+
234
+ return result;
235
+ }
236
+
237
+ // graphics.newHitTestOnlyMaskFromPaint( [opts] )
238
+ int
239
+ GraphicsLibrary::newHitTestOnlyMaskFromPaint ( lua_State *L )
240
+ {
241
+ lua_settop ( L, 0 ); // TODO: any options?
242
+ lua_pushliteral ( L, " " );
243
+
244
+ return newHitTestOnlyMask ( L );
245
+ }
246
+
206
247
// graphics.newVertexArray( x1, y1 [,x2, y2, ... ] )
207
248
/*
208
249
static int
@@ -921,6 +962,13 @@ LuaLibGraphics::Initialize( lua_State *L, Display& display )
921
962
922
963
CoronaLuaPushModule ( L, GraphicsLibrary::kName );
923
964
lua_setglobal ( L, GraphicsLibrary::kName ); // graphics = library
965
+
966
+ lua_newtable ( L );
967
+ lua_createtable ( L, 0 , 1 );
968
+ lua_pushliteral ( L, " k" );
969
+ lua_setfield ( L, -2 , " __mode" );
970
+ lua_setmetatable ( L, -2 );
971
+ lua_setfield ( L, LUA_REGISTRYINDEX, BitmapMask::kHitTestOnlyTable );
924
972
}
925
973
926
974
// ----------------------------------------------------------------------------
0 commit comments