@quenty/flipbook 3.0.0-canary.367.e9fdcbc.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,98 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
# [3.0.0
|
|
6
|
+
# [3.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/flipbook@2.19.0...@quenty/flipbook@3.0.0) (2023-10-11)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/flipbook
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [2.19.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/flipbook@2.18.0...@quenty/flipbook@2.19.0) (2023-09-21)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @quenty/flipbook
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [2.18.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/flipbook@2.17.0...@quenty/flipbook@2.18.0) (2023-09-04)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @quenty/flipbook
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# [2.17.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/flipbook@2.16.0...@quenty/flipbook@2.17.0) (2023-08-23)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @quenty/flipbook
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# [2.16.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/flipbook@2.15.0...@quenty/flipbook@2.16.0) (2023-08-01)
|
|
39
|
+
|
|
40
|
+
**Note:** Version bump only for package @quenty/flipbook
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
# [2.15.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/flipbook@2.14.0...@quenty/flipbook@2.15.0) (2023-07-28)
|
|
47
|
+
|
|
48
|
+
**Note:** Version bump only for package @quenty/flipbook
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
# [2.14.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/flipbook@2.13.0...@quenty/flipbook@2.14.0) (2023-07-25)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
### Features
|
|
58
|
+
|
|
59
|
+
* Add restFrame support to Flipbooks to control the frame the flipbooks rest on ([cbf5f4f](https://github.com/Quenty/NevermoreEngine/commit/cbf5f4f4211156144e150dd960d9e2225cf9c5f5))
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
# [2.13.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/flipbook@2.12.0...@quenty/flipbook@2.13.0) (2023-07-23)
|
|
66
|
+
|
|
67
|
+
**Note:** Version bump only for package @quenty/flipbook
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
# [2.12.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/flipbook@2.11.0...@quenty/flipbook@2.12.0) (2023-07-15)
|
|
74
|
+
|
|
75
|
+
**Note:** Version bump only for package @quenty/flipbook
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
# [2.11.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/flipbook@2.10.0...@quenty/flipbook@2.11.0) (2023-07-10)
|
|
82
|
+
|
|
83
|
+
**Note:** Version bump only for package @quenty/flipbook
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
# [2.10.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/flipbook@2.9.0...@quenty/flipbook@2.10.0) (2023-06-17)
|
|
90
|
+
|
|
91
|
+
**Note:** Version bump only for package @quenty/flipbook
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
# [2.9.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/flipbook@2.8.0...@quenty/flipbook@2.9.0) (2023-06-05)
|
|
7
98
|
|
|
8
99
|
**Note:** Version bump only for package @quenty/flipbook
|
|
9
100
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/flipbook",
|
|
3
|
-
"version": "3.0.0
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Handles playing back animated spritesheets",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -25,18 +25,18 @@
|
|
|
25
25
|
"Quenty"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@quenty/baseobject": "
|
|
29
|
-
"@quenty/instanceutils": "
|
|
30
|
-
"@quenty/loader": "
|
|
31
|
-
"@quenty/maid": "2.
|
|
32
|
-
"@quenty/promise": "
|
|
33
|
-
"@quenty/rx": "
|
|
34
|
-
"@quenty/sprites": "
|
|
35
|
-
"@quenty/uiobjectutils": "3.4.0",
|
|
36
|
-
"@quenty/valueobject": "8.0.0
|
|
28
|
+
"@quenty/baseobject": "^7.0.0",
|
|
29
|
+
"@quenty/instanceutils": "^8.0.0",
|
|
30
|
+
"@quenty/loader": "^7.0.0",
|
|
31
|
+
"@quenty/maid": "^2.6.0",
|
|
32
|
+
"@quenty/promise": "^7.0.0",
|
|
33
|
+
"@quenty/rx": "^8.0.0",
|
|
34
|
+
"@quenty/sprites": "^9.0.0",
|
|
35
|
+
"@quenty/uiobjectutils": "^3.4.0",
|
|
36
|
+
"@quenty/valueobject": "^8.0.0"
|
|
37
37
|
},
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "fdeae46099587019ec5fc15317dc673aed379400"
|
|
42
42
|
}
|
package/src/Client/Flipbook.lua
CHANGED
|
@@ -9,12 +9,13 @@ local Sprite = require("Sprite")
|
|
|
9
9
|
|
|
10
10
|
--[=[
|
|
11
11
|
@interface FlipbookData
|
|
12
|
-
.
|
|
12
|
+
.image string
|
|
13
13
|
.frameCount number
|
|
14
14
|
.rows number
|
|
15
15
|
.columns number
|
|
16
16
|
.imageRectSize Vector2
|
|
17
17
|
.frameRate number
|
|
18
|
+
.restFrame number | nil -- Optional reset frame
|
|
18
19
|
@within Flipbook
|
|
19
20
|
]=]
|
|
20
21
|
|
|
@@ -32,6 +33,9 @@ function Flipbook.new(data)
|
|
|
32
33
|
|
|
33
34
|
self._frameSprites = {}
|
|
34
35
|
self._frameRate = 60
|
|
36
|
+
self._restFrame = data.restFrame
|
|
37
|
+
|
|
38
|
+
assert(type(data.restFrame) == "number" or data.restFrame == nil, "Bad data.restFrame")
|
|
35
39
|
|
|
36
40
|
if data.frameCount then
|
|
37
41
|
self:SetFrameCount(data.frameCount)
|
|
@@ -84,6 +88,10 @@ function Flipbook:_loadFrames(image, columns, imageRectSize)
|
|
|
84
88
|
end
|
|
85
89
|
end
|
|
86
90
|
|
|
91
|
+
function Flipbook:GetRestFrame()
|
|
92
|
+
return self._restFrame
|
|
93
|
+
end
|
|
94
|
+
|
|
87
95
|
function Flipbook:SetSpriteAtIndex(index, sprite)
|
|
88
96
|
assert(type(index) == "number", "Bad index")
|
|
89
97
|
assert(type(sprite) == "table", "Bad sprite")
|
|
@@ -56,7 +56,15 @@ function FlipbookPlayer.new(imageLabel)
|
|
|
56
56
|
else
|
|
57
57
|
self._isPlaying.Value = false
|
|
58
58
|
self._maid._playing = nil
|
|
59
|
-
|
|
59
|
+
|
|
60
|
+
local restFrame = state.flipbook:GetRestFrame()
|
|
61
|
+
if restFrame then
|
|
62
|
+
self:_updateToFrame(state.flipbook, restFrame)
|
|
63
|
+
else
|
|
64
|
+
self._obj.Image = self._originalImage
|
|
65
|
+
self._obj.ImageRectOffset = self._originalRectOffset
|
|
66
|
+
self._obj.ImageRectSize = self._originalRectSize
|
|
67
|
+
end
|
|
60
68
|
end
|
|
61
69
|
else
|
|
62
70
|
self._isPlaying.Value = false
|
|
@@ -201,18 +209,20 @@ function FlipbookPlayer:_execPlay(flipbook, playData)
|
|
|
201
209
|
return maid
|
|
202
210
|
end
|
|
203
211
|
|
|
212
|
+
function FlipbookPlayer:_computeFrameCount(originalFrameCount, isBoomarang)
|
|
213
|
+
if isBoomarang then
|
|
214
|
+
return 2*originalFrameCount - 2
|
|
215
|
+
else
|
|
216
|
+
return originalFrameCount
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
|
|
204
220
|
function FlipbookPlayer:_update(flipbook, currentTime, playData)
|
|
205
221
|
local isBoomarang = self._isBoomarang.Value
|
|
206
222
|
local fps = flipbook:GetFrameRate()
|
|
207
223
|
local originalFrameCount = flipbook:GetFrameCount()
|
|
208
224
|
|
|
209
|
-
local frameCount
|
|
210
|
-
if isBoomarang then
|
|
211
|
-
frameCount = 2*originalFrameCount - 2
|
|
212
|
-
else
|
|
213
|
-
frameCount = originalFrameCount
|
|
214
|
-
end
|
|
215
|
-
|
|
225
|
+
local frameCount = self:_computeFrameCount(originalFrameCount, isBoomarang)
|
|
216
226
|
local frame = (math.floor((currentTime - playData.startTime)*fps)%frameCount) + 1
|
|
217
227
|
|
|
218
228
|
if isBoomarang then
|
|
@@ -237,7 +247,7 @@ function FlipbookPlayer:_update(flipbook, currentTime, playData)
|
|
|
237
247
|
end
|
|
238
248
|
|
|
239
249
|
if isOver then
|
|
240
|
-
self:_updateToFrame(flipbook,
|
|
250
|
+
self:_updateToFrame(flipbook, frameCount)
|
|
241
251
|
self._playData.Value = nil
|
|
242
252
|
else
|
|
243
253
|
self:_updateToFrame(flipbook, frame)
|
|
@@ -90,6 +90,7 @@ return function(target)
|
|
|
90
90
|
frameCount = 34;
|
|
91
91
|
imageRectSize = Vector2.new(85.33333, 85.33333);
|
|
92
92
|
frameRate = 20;
|
|
93
|
+
restFrame = 1;
|
|
93
94
|
}), container, false)
|
|
94
95
|
|
|
95
96
|
makeLabel(maid, Flipbook.new({
|
|
@@ -99,6 +100,7 @@ return function(target)
|
|
|
99
100
|
frameCount = 34;
|
|
100
101
|
imageRectSize = Vector2.new(85.33333, 85.33333);
|
|
101
102
|
frameRate = 20;
|
|
103
|
+
restFrame = 1;
|
|
102
104
|
}), container, true)
|
|
103
105
|
|
|
104
106
|
makeLabel(maid, Flipbook.new({
|
|
@@ -107,6 +109,7 @@ return function(target)
|
|
|
107
109
|
columns = 6;
|
|
108
110
|
imageRectSize = Vector2.new(170, 170);
|
|
109
111
|
frameRate = 50;
|
|
112
|
+
restFrame = 1;
|
|
110
113
|
}), container, false)
|
|
111
114
|
|
|
112
115
|
makeLabel(maid, Flipbook.new({
|
|
@@ -116,6 +119,7 @@ return function(target)
|
|
|
116
119
|
frameCount = 92;
|
|
117
120
|
imageRectSize = Vector2.new(102, 102);
|
|
118
121
|
frameRate = 50;
|
|
122
|
+
restFrame = 1;
|
|
119
123
|
}), container, false)
|
|
120
124
|
|
|
121
125
|
makeButton(maid, Flipbook.new({
|
|
@@ -125,6 +129,7 @@ return function(target)
|
|
|
125
129
|
frameCount = 92;
|
|
126
130
|
imageRectSize = Vector2.new(102, 102);
|
|
127
131
|
frameRate = 60;
|
|
132
|
+
restFrame = 1;
|
|
128
133
|
}), container, false)
|
|
129
134
|
|
|
130
135
|
makeButton(maid, Flipbook.new({
|
|
@@ -134,6 +139,7 @@ return function(target)
|
|
|
134
139
|
frameCount = 34;
|
|
135
140
|
imageRectSize = Vector2.new(85.33333, 85.33333);
|
|
136
141
|
frameRate = 20;
|
|
142
|
+
restFrame = 1;
|
|
137
143
|
}), container, true)
|
|
138
144
|
|
|
139
145
|
makeLabel(maid, Flipbook.new({
|
|
@@ -143,6 +149,7 @@ return function(target)
|
|
|
143
149
|
frameCount = 92;
|
|
144
150
|
imageRectSize = Vector2.new(102, 102);
|
|
145
151
|
frameRate = 50;
|
|
152
|
+
restFrame = 1;
|
|
146
153
|
}), container, false)
|
|
147
154
|
|
|
148
155
|
makeLabel(maid, Flipbook.new({
|
|
@@ -152,6 +159,7 @@ return function(target)
|
|
|
152
159
|
frameCount = 45;
|
|
153
160
|
imageRectSize = Vector2.new(146, 146);
|
|
154
161
|
frameRate = 30;
|
|
162
|
+
restFrame = 1;
|
|
155
163
|
}), container, false)
|
|
156
164
|
|
|
157
165
|
makeLabel(maid, Flipbook.new({
|
|
@@ -161,6 +169,7 @@ return function(target)
|
|
|
161
169
|
frameCount = 66;
|
|
162
170
|
imageRectSize = Vector2.new(113, 113);
|
|
163
171
|
frameRate = 60;
|
|
172
|
+
restFrame = 1;
|
|
164
173
|
}), container, false)
|
|
165
174
|
|
|
166
175
|
return function()
|