@quenty/sprites 9.0.0 → 9.1.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 +11 -0
- package/package.json +2 -2
- package/src/Shared/InputImageLibrary/InputImageLibrary.story.lua +20 -13
- package/src/Shared/InputImageLibrary/Spritesheets/PlayStation/Dark.lua +45 -0
- package/src/Shared/InputImageLibrary/init.lua +85 -15
- package/src/Shared/Sprite/Sprite.lua +4 -0
- package/src/Shared/Sprite/Spritesheet.lua +16 -16
- /package/src/Shared/InputImageLibrary/Spritesheets/{Guestures → Touch}/All.lua +0 -0
- /package/src/Shared/InputImageLibrary/Spritesheets/{XboxOne → XBox}/Dark.lua +0 -0
- /package/src/Shared/InputImageLibrary/Spritesheets/{XboxOne → XBox}/Light.lua +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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
|
+
# [9.1.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sprites@9.0.0...@quenty/sprites@9.1.0) (2023-10-11)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Support PS5 icons in input image library ([9e75b62](https://github.com/Quenty/NevermoreEngine/commit/9e75b6205a536bd5f6d9136ad25282c0ade24c94))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [9.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sprites@8.3.0...@quenty/sprites@9.0.0) (2023-10-11)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @quenty/sprites
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/sprites",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.1.0",
|
|
4
4
|
"description": "Spritesheet utility for Roblox including a built-in InputImageLibrary",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "eddeed5f503f338926e804d9c11297139f447c6f"
|
|
41
41
|
}
|
|
@@ -10,7 +10,7 @@ local UIPaddingUtils = require("UIPaddingUtils")
|
|
|
10
10
|
local UICornerUtils = require("UICornerUtils")
|
|
11
11
|
local String = require("String")
|
|
12
12
|
|
|
13
|
-
local
|
|
13
|
+
local CONSOLE = {
|
|
14
14
|
Enum.KeyCode.ButtonA;
|
|
15
15
|
Enum.KeyCode.ButtonB;
|
|
16
16
|
Enum.KeyCode.ButtonX;
|
|
@@ -90,7 +90,7 @@ local MOUSE = {
|
|
|
90
90
|
Enum.UserInputType.MouseMovement;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
local function
|
|
93
|
+
local function createInputKey(keyCode, theme, platform, parent)
|
|
94
94
|
local container = Instance.new("Frame")
|
|
95
95
|
container.BorderSizePixel = 0
|
|
96
96
|
container.Size = UDim2.new(1, 0, 1, 0)
|
|
@@ -117,7 +117,7 @@ local function create(keyCode, theme, parent)
|
|
|
117
117
|
local uiListLayout = Instance.new("UIListLayout")
|
|
118
118
|
uiListLayout.Parent = container
|
|
119
119
|
|
|
120
|
-
local sprite = InputImageLibrary:GetScaledImageLabel(keyCode, theme)
|
|
120
|
+
local sprite = InputImageLibrary:GetScaledImageLabel(keyCode, theme, platform)
|
|
121
121
|
sprite.Parent = container
|
|
122
122
|
|
|
123
123
|
container.Parent = parent
|
|
@@ -141,11 +141,13 @@ local function makeTitle(title, parent)
|
|
|
141
141
|
return titleLabel
|
|
142
142
|
end
|
|
143
143
|
|
|
144
|
-
local function makeSection(keycodes, theme, parent)
|
|
144
|
+
local function makeSection(keycodes, theme, platform, parent)
|
|
145
145
|
local container = Instance.new("Frame")
|
|
146
146
|
container.BorderSizePixel = 0
|
|
147
147
|
container.BackgroundTransparency = 1
|
|
148
|
-
container.Size = UDim2.new(1, 0,
|
|
148
|
+
container.Size = UDim2.new(1, 0, 0, 0)
|
|
149
|
+
container.BackgroundColor3 = Color3.new(0.5, 0, 0)
|
|
150
|
+
container.AutomaticSize = Enum.AutomaticSize.Y
|
|
149
151
|
|
|
150
152
|
local uiGridLayout = Instance.new("UIGridLayout")
|
|
151
153
|
uiGridLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center
|
|
@@ -156,11 +158,10 @@ local function makeSection(keycodes, theme, parent)
|
|
|
156
158
|
uiGridLayout.Parent = container
|
|
157
159
|
|
|
158
160
|
for _, item in pairs(keycodes) do
|
|
159
|
-
|
|
161
|
+
createInputKey(item, theme, platform, container)
|
|
160
162
|
end
|
|
161
163
|
|
|
162
164
|
container.Parent = parent
|
|
163
|
-
container.Size = UDim2.new(1, 0, 0, uiGridLayout.AbsoluteContentSize.y)
|
|
164
165
|
|
|
165
166
|
return container
|
|
166
167
|
end
|
|
@@ -189,22 +190,28 @@ return function(target)
|
|
|
189
190
|
end
|
|
190
191
|
|
|
191
192
|
add(makeTitle("Mouse Light", scrollingFrame))
|
|
192
|
-
add(makeSection(MOUSE, "Light", scrollingFrame))
|
|
193
|
+
add(makeSection(MOUSE, "Light", nil, scrollingFrame))
|
|
193
194
|
|
|
194
195
|
add(makeTitle("Mouse Dark", scrollingFrame))
|
|
195
|
-
add(makeSection(MOUSE, "Dark", scrollingFrame))
|
|
196
|
+
add(makeSection(MOUSE, "Dark", nil, scrollingFrame))
|
|
196
197
|
|
|
197
198
|
add(makeTitle("XBox Dark", scrollingFrame))
|
|
198
|
-
add(makeSection(
|
|
199
|
+
add(makeSection(CONSOLE, "Dark", "XBox", scrollingFrame))
|
|
199
200
|
|
|
200
201
|
add(makeTitle("XBox Light", scrollingFrame))
|
|
201
|
-
add(makeSection(
|
|
202
|
+
add(makeSection(CONSOLE, "Light", "XBox", scrollingFrame))
|
|
203
|
+
|
|
204
|
+
add(makeTitle("PS5 Dark", scrollingFrame))
|
|
205
|
+
add(makeSection(CONSOLE, "Dark", "PlayStation", scrollingFrame))
|
|
206
|
+
|
|
207
|
+
add(makeTitle("PS5 Light", scrollingFrame))
|
|
208
|
+
add(makeSection(CONSOLE, "Light", "PlayStation", scrollingFrame))
|
|
202
209
|
|
|
203
210
|
add(makeTitle("Keyboard Dark", scrollingFrame))
|
|
204
|
-
add(makeSection(KEYBOARD, "Dark", scrollingFrame))
|
|
211
|
+
add(makeSection(KEYBOARD, "Dark", nil, scrollingFrame))
|
|
205
212
|
|
|
206
213
|
add(makeTitle("Keyboard Light", scrollingFrame))
|
|
207
|
-
add(makeSection(KEYBOARD, "Light", scrollingFrame))
|
|
214
|
+
add(makeSection(KEYBOARD, "Light", nil, scrollingFrame))
|
|
208
215
|
|
|
209
216
|
|
|
210
217
|
return function()
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
--[[
|
|
2
|
+
Generated PS5Dark with Python
|
|
3
|
+
@class PS5Dark
|
|
4
|
+
]]
|
|
5
|
+
|
|
6
|
+
local parent = script:FindFirstAncestorWhichIsA("ModuleScript")
|
|
7
|
+
local require = require(parent.Parent.loader).load(parent)
|
|
8
|
+
|
|
9
|
+
local Spritesheet = require("Spritesheet")
|
|
10
|
+
|
|
11
|
+
local PS5Dark = setmetatable({}, Spritesheet)
|
|
12
|
+
PS5Dark.ClassName = "PS5Dark"
|
|
13
|
+
PS5Dark.__index = PS5Dark
|
|
14
|
+
|
|
15
|
+
function PS5Dark.new()
|
|
16
|
+
local self = setmetatable(Spritesheet.new("rbxassetid://15030465512"), PS5Dark)
|
|
17
|
+
|
|
18
|
+
self:AddSprite("DPad", Vector2.new(0, 0), Vector2.new(100, 100))
|
|
19
|
+
self:AddSprite("Microphone", Vector2.new(100, 0), Vector2.new(100, 100))
|
|
20
|
+
self:AddSprite("Options", Vector2.new(200, 0), Vector2.new(100, 100))
|
|
21
|
+
self:AddSprite("OptionsAlt", Vector2.new(300, 0), Vector2.new(100, 100))
|
|
22
|
+
self:AddSprite("ShareAlt", Vector2.new(400, 0), Vector2.new(100, 100))
|
|
23
|
+
self:AddSprite("Thumbstick1_Click", Vector2.new(500, 0), Vector2.new(100, 100))
|
|
24
|
+
self:AddSprite("Thumbstick2_Click", Vector2.new(600, 0), Vector2.new(100, 100))
|
|
25
|
+
self:AddSprite("TouchPad", Vector2.new(700, 0), Vector2.new(100, 100))
|
|
26
|
+
self:AddSprite(Enum.KeyCode.ButtonA, Vector2.new(800, 0), Vector2.new(100, 100))
|
|
27
|
+
self:AddSprite(Enum.KeyCode.ButtonB, Vector2.new(900, 0), Vector2.new(100, 100))
|
|
28
|
+
self:AddSprite(Enum.KeyCode.ButtonL1, Vector2.new(0, 100), Vector2.new(100, 100))
|
|
29
|
+
self:AddSprite(Enum.KeyCode.ButtonL2, Vector2.new(100, 100), Vector2.new(100, 100))
|
|
30
|
+
self:AddSprite(Enum.KeyCode.ButtonR1, Vector2.new(200, 100), Vector2.new(100, 100))
|
|
31
|
+
self:AddSprite(Enum.KeyCode.ButtonR2, Vector2.new(300, 100), Vector2.new(100, 100))
|
|
32
|
+
self:AddSprite(Enum.KeyCode.ButtonSelect, Vector2.new(400, 100), Vector2.new(100, 100))
|
|
33
|
+
self:AddSprite(Enum.KeyCode.ButtonX, Vector2.new(500, 100), Vector2.new(100, 100))
|
|
34
|
+
self:AddSprite(Enum.KeyCode.ButtonY, Vector2.new(600, 100), Vector2.new(100, 100))
|
|
35
|
+
self:AddSprite(Enum.KeyCode.DPadDown, Vector2.new(700, 100), Vector2.new(100, 100))
|
|
36
|
+
self:AddSprite(Enum.KeyCode.DPadLeft, Vector2.new(800, 100), Vector2.new(100, 100))
|
|
37
|
+
self:AddSprite(Enum.KeyCode.DPadRight, Vector2.new(900, 100), Vector2.new(100, 100))
|
|
38
|
+
self:AddSprite(Enum.KeyCode.DPadUp, Vector2.new(0, 200), Vector2.new(100, 100))
|
|
39
|
+
self:AddSprite(Enum.KeyCode.Thumbstick1, Vector2.new(100, 200), Vector2.new(100, 100))
|
|
40
|
+
self:AddSprite(Enum.KeyCode.Thumbstick2, Vector2.new(200, 200), Vector2.new(100, 100))
|
|
41
|
+
|
|
42
|
+
return self
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
return PS5Dark
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
local require = require(script.Parent.loader).load(script)
|
|
9
9
|
|
|
10
|
+
local UserInputService = game:GetService("UserInputService")
|
|
11
|
+
|
|
10
12
|
local SUPRESS_UNFOUND_IMAGE_WARNING = true
|
|
11
13
|
|
|
12
14
|
local InputImageLibrary = {}
|
|
@@ -38,6 +40,8 @@ function InputImageLibrary:GetPreloadAssetIds()
|
|
|
38
40
|
end
|
|
39
41
|
|
|
40
42
|
function InputImageLibrary:_loadSpriteSheets(parentFolder)
|
|
43
|
+
assert(typeof(parentFolder) == "Instance", "Bad parentFolder")
|
|
44
|
+
|
|
41
45
|
for _, platform in pairs(parentFolder:GetChildren()) do
|
|
42
46
|
self._spritesheets[platform.Name] = {}
|
|
43
47
|
for _, style in pairs(platform:GetChildren()) do
|
|
@@ -51,21 +55,74 @@ end
|
|
|
51
55
|
--[=[
|
|
52
56
|
Retrieves a sprite from the library
|
|
53
57
|
|
|
54
|
-
@param
|
|
58
|
+
@param keyCode any -- The sprite keyCode to get
|
|
55
59
|
@param preferredStyle string -- The preferred style type to retrieve this in
|
|
56
60
|
@param preferredPlatform string -- The preferred platform to get the sprite for
|
|
57
61
|
@return Sprite
|
|
58
62
|
]=]
|
|
59
|
-
function InputImageLibrary:GetSprite(
|
|
60
|
-
|
|
63
|
+
function InputImageLibrary:GetSprite(keyCode, preferredStyle, preferredPlatform)
|
|
64
|
+
assert(keyCode ~= nil, "Bad keyCode")
|
|
65
|
+
assert(type(preferredStyle) == "string" or preferredStyle == nil, "Bad preferredStyle")
|
|
66
|
+
assert(type(preferredPlatform) == "string" or preferredPlatform == nil, "Bad preferredPlatform")
|
|
67
|
+
|
|
68
|
+
local sheet = self:PickSheet(keyCode, preferredStyle, preferredPlatform)
|
|
61
69
|
if sheet then
|
|
62
|
-
return sheet:GetSprite(
|
|
70
|
+
return sheet:GetSprite(keyCode)
|
|
63
71
|
end
|
|
64
72
|
|
|
65
73
|
return nil
|
|
66
74
|
end
|
|
67
75
|
|
|
76
|
+
--[=[
|
|
77
|
+
Styles a GUI for a specific keycode
|
|
78
|
+
|
|
79
|
+
```lua
|
|
80
|
+
local InputImageLibrary = require("InputImageLibrary")
|
|
81
|
+
InputImageLibrary:StyleImage(script.Parent, Enum.KeyCode.ButtonA)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
@param gui ImageLabel | ImageButton
|
|
85
|
+
@param keyCode any -- The sprite keyCode to get
|
|
86
|
+
@param preferredStyle string -- The preferred style type to retrieve this in
|
|
87
|
+
@param preferredPlatform string -- The preferred platform to get the sprite for
|
|
88
|
+
@return Sprite
|
|
89
|
+
]=]
|
|
90
|
+
function InputImageLibrary:StyleImage(gui, keyCode, preferredStyle, preferredPlatform)
|
|
91
|
+
assert(typeof(gui) == "Instance" and (gui:IsA("ImageLabel") or gui:IsA("ImageButton")), "Bad gui")
|
|
92
|
+
assert(keyCode ~= nil, "Bad keyCode")
|
|
93
|
+
assert(type(preferredStyle) == "string" or preferredStyle == nil, "Bad preferredStyle")
|
|
94
|
+
assert(type(preferredPlatform) == "string" or preferredPlatform == nil, "Bad preferredPlatform")
|
|
95
|
+
|
|
96
|
+
local sheet = self:PickSheet(keyCode, preferredStyle, preferredPlatform)
|
|
97
|
+
if sheet then
|
|
98
|
+
return sheet:GetSprite(keyCode):Style(gui)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
return nil
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
function InputImageLibrary:_getDefaultPreferredPlatform()
|
|
105
|
+
-- Hack to select the right preferred platform
|
|
106
|
+
-- TODO: Maybe pass this into our selector?
|
|
107
|
+
local result = UserInputService:GetImageForKeyCode(Enum.KeyCode.ButtonA)
|
|
108
|
+
if not result then
|
|
109
|
+
return nil
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
if string.find(result, "PlayStation") then
|
|
113
|
+
return "PlayStation"
|
|
114
|
+
elseif string.find(result, "Xbox") then
|
|
115
|
+
return "XBox"
|
|
116
|
+
else
|
|
117
|
+
return "XBox"
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
68
121
|
function InputImageLibrary:GetScaledImageLabel(keyCode, preferredStyle, preferredPlatform)
|
|
122
|
+
assert(keyCode ~= nil, "Bad keyCode")
|
|
123
|
+
assert(type(preferredStyle) == "string" or preferredStyle == nil, "Bad preferredStyle")
|
|
124
|
+
assert(type(preferredPlatform) == "string" or preferredPlatform == nil, "Bad preferredPlatform")
|
|
125
|
+
|
|
69
126
|
local image = self:_getImageInstance("ImageLabel", keyCode, preferredStyle or "Dark", preferredPlatform)
|
|
70
127
|
if not image then
|
|
71
128
|
return nil
|
|
@@ -84,25 +141,33 @@ function InputImageLibrary:GetScaledImageLabel(keyCode, preferredStyle, preferre
|
|
|
84
141
|
return image
|
|
85
142
|
end
|
|
86
143
|
|
|
87
|
-
function InputImageLibrary:
|
|
144
|
+
function InputImageLibrary:PickSheet(keyCode, preferredStyle, preferredPlatform)
|
|
145
|
+
assert(keyCode ~= nil, "Bad keyCode")
|
|
146
|
+
assert(type(preferredStyle) == "string" or preferredStyle == nil, "Bad preferredStyle")
|
|
147
|
+
assert(type(preferredPlatform) == "string" or preferredPlatform == nil, "Bad preferredPlatform")
|
|
148
|
+
|
|
88
149
|
local function findSheet(platformSheets)
|
|
89
150
|
local preferredSheet = platformSheets[preferredStyle]
|
|
90
|
-
if preferredSheet and preferredSheet:HasSprite(
|
|
151
|
+
if preferredSheet and preferredSheet:HasSprite(keyCode) then
|
|
91
152
|
return preferredSheet
|
|
92
153
|
end
|
|
93
154
|
|
|
94
155
|
-- otherwise search (yes, we double hit a sheet)
|
|
95
156
|
for _, sheet in pairs(platformSheets) do
|
|
96
|
-
if sheet:HasSprite(
|
|
157
|
+
if sheet:HasSprite(keyCode) then
|
|
97
158
|
return sheet
|
|
98
159
|
end
|
|
99
160
|
end
|
|
100
161
|
end
|
|
101
162
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if
|
|
105
|
-
|
|
163
|
+
preferredPlatform = preferredPlatform or self:_getDefaultPreferredPlatform()
|
|
164
|
+
|
|
165
|
+
if preferredPlatform then
|
|
166
|
+
local sheet = self._spritesheets[preferredPlatform]
|
|
167
|
+
local preferredSheet = sheet and findSheet(sheet)
|
|
168
|
+
if preferredSheet and preferredSheet:HasSprite(keyCode) then
|
|
169
|
+
return preferredSheet
|
|
170
|
+
end
|
|
106
171
|
end
|
|
107
172
|
|
|
108
173
|
-- otherwise search (repeats preferred :/ )
|
|
@@ -114,17 +179,22 @@ function InputImageLibrary:_pickSheet(index, preferredStyle, preferredPlatform)
|
|
|
114
179
|
end
|
|
115
180
|
|
|
116
181
|
if not SUPRESS_UNFOUND_IMAGE_WARNING then
|
|
117
|
-
warn("[InputImageLibrary] - Unable to find sprite for", tostring(
|
|
182
|
+
warn("[InputImageLibrary] - Unable to find sprite for", tostring(keyCode), "type", typeof(keyCode))
|
|
118
183
|
end
|
|
119
184
|
|
|
120
185
|
return nil
|
|
121
186
|
end
|
|
122
187
|
|
|
123
188
|
|
|
124
|
-
function InputImageLibrary:_getImageInstance(instanceType,
|
|
125
|
-
|
|
189
|
+
function InputImageLibrary:_getImageInstance(instanceType, keyCode, preferredStyle, preferredPlatform)
|
|
190
|
+
assert(type(instanceType) == "string", "Bad instanceType")
|
|
191
|
+
assert(keyCode ~= nil, "Bad keyCode")
|
|
192
|
+
assert(type(preferredStyle) == "string" or preferredStyle == nil, "Bad preferredStyle")
|
|
193
|
+
assert(type(preferredPlatform) == "string" or preferredPlatform == nil, "Bad preferredPlatform")
|
|
194
|
+
|
|
195
|
+
local sheet = self:PickSheet(keyCode, preferredStyle, preferredPlatform)
|
|
126
196
|
if sheet then
|
|
127
|
-
return sheet:GetSprite(
|
|
197
|
+
return sheet:GetSprite(keyCode):Get(instanceType)
|
|
128
198
|
end
|
|
129
199
|
|
|
130
200
|
return nil
|
|
@@ -39,6 +39,8 @@ end
|
|
|
39
39
|
@return Instance
|
|
40
40
|
]=]
|
|
41
41
|
function Sprite:Style(gui)
|
|
42
|
+
assert(typeof(gui) == "Instance" and (gui:IsA("ImageLabel") or gui:IsA("ImageButton")), "Bad gui")
|
|
43
|
+
|
|
42
44
|
gui.Image = self.Texture
|
|
43
45
|
gui.ImageRectOffset = self.Position
|
|
44
46
|
gui.ImageRectSize = self.Size
|
|
@@ -52,6 +54,8 @@ end
|
|
|
52
54
|
@return ImageLabel | ImageButton
|
|
53
55
|
]=]
|
|
54
56
|
function Sprite:Get(instanceType)
|
|
57
|
+
assert(type(instanceType) == "string", "Bad instanceType")
|
|
58
|
+
|
|
55
59
|
local gui = Instance.new(instanceType)
|
|
56
60
|
gui.Size = UDim2.new(0, self.Size.X, 0, self.Size.Y)
|
|
57
61
|
gui.Name = self.Name
|
|
@@ -34,43 +34,43 @@ function Spritesheet:GetPreloadAssetId()
|
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
--[=[
|
|
37
|
-
@param
|
|
37
|
+
@param keyCode any
|
|
38
38
|
@param position Vector2
|
|
39
39
|
@param size Vector2
|
|
40
40
|
|
|
41
|
-
Adds a named sprite at the given
|
|
41
|
+
Adds a named sprite at the given keyCode
|
|
42
42
|
]=]
|
|
43
|
-
function Spritesheet:AddSprite(
|
|
44
|
-
assert(not self._sprites[
|
|
43
|
+
function Spritesheet:AddSprite(keyCode, position, size)
|
|
44
|
+
assert(not self._sprites[keyCode], "Already exists")
|
|
45
45
|
|
|
46
46
|
local sprite = Sprite.new({
|
|
47
47
|
Texture = self._texture;
|
|
48
48
|
Position = position;
|
|
49
49
|
Size = size;
|
|
50
|
-
Name = tostring(
|
|
50
|
+
Name = tostring(keyCode);
|
|
51
51
|
})
|
|
52
52
|
|
|
53
|
-
self._sprites[
|
|
53
|
+
self._sprites[keyCode] = sprite
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
--[=[
|
|
57
|
-
Retrieves the sprite for the given
|
|
58
|
-
@param
|
|
57
|
+
Retrieves the sprite for the given keyCode
|
|
58
|
+
@param keyCode any | EnumItem
|
|
59
59
|
@return Sprite?
|
|
60
60
|
]=]
|
|
61
|
-
function Spritesheet:GetSprite(
|
|
62
|
-
if not
|
|
61
|
+
function Spritesheet:GetSprite(keyCode)
|
|
62
|
+
if not keyCode then
|
|
63
63
|
warn("[Spritesheet.GetSprite] - Image name cannot be nil")
|
|
64
64
|
return nil
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
-
local sprite = self._sprites[
|
|
67
|
+
local sprite = self._sprites[keyCode]
|
|
68
68
|
if sprite then
|
|
69
69
|
return sprite
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
-
if typeof(
|
|
73
|
-
sprite = self._sprites[
|
|
72
|
+
if typeof(keyCode) == "EnumItem" then
|
|
73
|
+
sprite = self._sprites[keyCode.Name]
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
return sprite
|
|
@@ -78,11 +78,11 @@ end
|
|
|
78
78
|
|
|
79
79
|
--[=[
|
|
80
80
|
Returns true if the sprite exists
|
|
81
|
-
@param
|
|
81
|
+
@param keyCode any | EnumItem
|
|
82
82
|
@return boolean
|
|
83
83
|
]=]
|
|
84
|
-
function Spritesheet:HasSprite(
|
|
85
|
-
return self:GetSprite(
|
|
84
|
+
function Spritesheet:HasSprite(keyCode)
|
|
85
|
+
return self:GetSprite(keyCode) ~= nil
|
|
86
86
|
end
|
|
87
87
|
|
|
88
88
|
return Spritesheet
|
|
File without changes
|
|
File without changes
|
|
File without changes
|