@@ -56,9 +56,12 @@ peachy.__index = peachy
56
56
-- @return the new Peachy object.
57
57
function peachy .new (dataFile , imageData , initialTag )
58
58
assert (dataFile ~= nil , " No JSON data!" )
59
-
59
+
60
60
local self = setmetatable ({}, peachy )
61
-
61
+
62
+ -- store the path to the passed json file
63
+ self .json_path = dataFile
64
+
62
65
-- check if datafile is a lua table (i.e. pre decoded)
63
66
if type (dataFile ) == ' table' then
64
67
self ._jsonData = dataFile
@@ -134,6 +137,24 @@ function peachy:setFrame(frame)
134
137
self .frameTimer = cron .after (self .frame .duration , self .nextFrame , self )
135
138
end
136
139
140
+ --- Get the current frame of the current animation
141
+ -- @usage
142
+ -- Get the 2nd frame
143
+ -- local f = sound:getFrame()
144
+ --
145
+ function peachy :getFrame ()
146
+ return self .frameIndex
147
+ end
148
+
149
+ --- Get the json path passed in the object
150
+ -- @usage
151
+ -- Get the (string) JSON path
152
+ -- local str_json = obj:getJSON()
153
+ --
154
+ function peachy :getJSON ()
155
+ return self .json_path
156
+ end
157
+
137
158
--- Draw the animation's current frame in a specified location.
138
159
-- @tparam number x the x position.
139
160
-- @tparam number y the y position.
@@ -251,6 +272,11 @@ function peachy:getHeight()
251
272
return self ._jsonData .frames [self .frameIndex ].frame .h
252
273
end
253
274
275
+ --- Provides dimensions stored in the metadata of a current frame
276
+ function peachy :getDimensions ()
277
+ return self :getWidth (), self :getHeight ()
278
+ end
279
+
254
280
--- Internal: handles the ping-pong animation type.
255
281
--
256
282
-- Should only be called when we actually want to bounce.
0 commit comments