-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheventlib.lua
197 lines (157 loc) · 4.95 KB
/
eventlib.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
-- event lib
--[[ internal values ]]--
local stage = display.getCurrentStage()
--[[ ease of use ]]--
-- Easy-access function for dispatching events to the stage
function dispatchEvent( event )
stage:dispatchEvent( event )
end
-- Easy-access function for adding event listeners to the stage
function addEventListener( name, event )
stage:addEventListener( name, event )
end
-- Easy-access function for removing event listeners to the stage
function removeEventListener( name, event )
stage:removeEventListener( name, event )
end
--[[ display.* ]]--
local newcircle = display.newCircle
display.newCircle = function(...)
local circle = newcircle(unpack({...}))
dispatchEvent{ name="newCircle", target=circle, arg={...} }
return circle
end
local newembossedtext = display.newEmbossedText
display.newEmbossedText = function(...)
local embossedtext = newembossedtext(unpack({...}))
dispatchEvent{ name="newEmbossedText", target=embossedtext, arg={...} }
return embossedtext
end
local newgroup = display.newGroup
display.newGroup = function(...)
local group = newgroup(unpack({...}))
dispatchEvent{ name="newGroup", target=group, arg={...} }
return group
end
local newimage = display.newImage
display.newImage = function(...)
local image = newimage(unpack({...}))
dispatchEvent{ name="newImage", target=image, arg={...} }
return image
end
local newimagegroup = display.newImageGroup
display.newImageGroup = function(...)
local imagegroup = newimagegroup(unpack({...}))
dispatchEvent{ name="newImageGroup", target=imagegroup, arg={...} }
return imagegroup
end
local newimagerect = display.newImageRect
display.newImageRect = function(...)
local imagerect = newimagerect(unpack({...}))
dispatchEvent{ name="newImageRect", target=imagerect, arg={...} }
return imagerect
end
local newline = display.newLine
display.newLine = function(...)
local line = newline(unpack({...}))
dispatchEvent{ name="newLine", target=line, arg={...} }
return line
end
local newrect = display.newRect
display.newRect = function(...)
local rect = newrect(unpack({...}))
dispatchEvent{ name="newRect", target=rect, arg={...} }
return rect
end
local newroundedrect = display.newRoundedRect
display.newRoundedRect = function(...)
local roundedrect = newroundedrect(unpack({...}))
dispatchEvent{ name="newRoundedRect", target=roundedrect, arg={...} }
return roundedrect
end
local newsprite = display.newSprite
display.newSprite = function(...)
local sprite = newsprite(unpack({...}))
dispatchEvent{ name="newSprite", target=sprite, arg={...} }
return sprite
end
local newtext = display.newText
display.newText = function(...)
local text = newtext(unpack({...}))
dispatchEvent{ name="newText", target=text, arg={...} }
return text
end
--[[ graphics.* ]]--
local newgradient = graphics.newGradient
graphics.newGradient = function(...)
local gradient = newgradient(unpack({...}))
dispatchEvent{ name="newGradient", target=gradient, arg={...} }
return gradient
end
local newimagesheet = graphics.newImageSheet
graphics.newImageSheet = function(...)
local imagesheet = newimagesheet(unpack({...}))
dispatchEvent{ name="newImageSheet", target=imagesheet, arg={...} }
return imagesheet
end
local newmask = graphics.newMask
graphics.newMask = function(...)
local mask = newmask(unpack({...}))
dispatchEvent{ name="newMask", target=mask, arg={...} }
return mask
end
--[[ physics.* ]]--
local hasphysics = pcall(function()
local f = physics.start
end)
if (hasphysics) then
local addbody = physics.addBody
physics.addBody = function(...)
local body = addbody(unpack({...}))
dispatchEvent{ name="addBody", target=body, arg={...} }
return body
end
local newjoint = physics.newJoint
physics.newJoint = function(...)
local joint = newjoint(unpack({...}))
dispatchEvent{ name="newJoint", target=joint, arg={...} }
return joint
end
local newpause = physics.pause
physics.pause = function(...)
local pause = newpause(unpack({...}))
dispatchEvent{ name="pause", target=pause, arg={...} }
return pause
end
local newremovebody = physics.removeBody
physics.removeBody = function(...)
local removebody = newremovebody(unpack({...}))
dispatchEvent{ name="removeBody", target=removebody, arg={...} }
return removebody
end
local newsetgravity = physics.setGravity
physics.setGravity = function(...)
local setgravity = newsetgravity(unpack({...}))
dispatchEvent{ name="setGravity", target=setgravity, arg={...} }
return setgravity
end
local newstart = physics.start
physics.start = function(...)
local start = newstart(unpack({...}))
dispatchEvent{ name="start", target=start, arg={...} }
return start
end
local newstop = physics.stop
physics.stop = function(...)
local stop = newstop(unpack({...}))
dispatchEvent{ name="stop", target=stop, arg={...} }
return stop
end
end
--[[ object.* ]]--
local newaddeventlistener = graphics.newMask
graphics.newMask = function(...)
local mask = newmask(unpack({...}))
dispatchEvent{ name="newMask", target=mask, arg={...} }
return mask
end