@quenty/sprites 7.3.0 → 8.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,6 +3,14 @@
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
+ # [8.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sprites@7.3.0...@quenty/sprites@8.0.0) (2023-03-06)
7
+
8
+ **Note:** Version bump only for package @quenty/sprites
9
+
10
+
11
+
12
+
13
+
6
14
  # [7.3.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sprites@7.2.0...@quenty/sprites@7.3.0) (2023-03-05)
7
15
 
8
16
  **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": "7.3.0",
3
+ "version": "8.0.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": "e62b5eac2e5d9084ab9083f128452dd2d98b6f1a"
40
+ "gitHead": "2e5e9b3fa1c8d585a9c522e627fd86b950d16502"
41
41
  }
@@ -1,82 +0,0 @@
1
- --[=[
2
- A spritesheet that is animated. See [AnimatedSpritesheetPlayer] for playback.
3
- @class AnimatedSpritesheet
4
- ]=]
5
-
6
- local require = require(script.Parent.loader).load(script)
7
-
8
- local Spritesheet = require("Spritesheet")
9
-
10
- local AnimatedSpritesheet = setmetatable({}, Spritesheet)
11
- AnimatedSpritesheet.ClassName = "AnimatedSpritesheet"
12
- AnimatedSpritesheet.__index = AnimatedSpritesheet
13
-
14
- --[=[
15
- @interface AnimatedSpritesheetOptions
16
- .texture string
17
- .frames number
18
- .spritesPerRow number
19
- .spriteSize Vector2
20
- .framesPerSecond number
21
- @within AnimatedSpritesheet
22
- ]=]
23
-
24
- --[=[
25
- Constructs a new AnimatedSpritesheet
26
- @param options AnimatedSpritesheetOptions
27
- @return AnimatedSpritesheet
28
- ]=]
29
- function AnimatedSpritesheet.new(options)
30
- local self = setmetatable(Spritesheet.new(options.texture), AnimatedSpritesheet)
31
-
32
- self._options = assert(options, "Bad options")
33
- assert(self._options.texture, "Bad options.texture")
34
- assert(self._options.frames, "Bad options.frames")
35
- assert(self._options.spritesPerRow, "Bad options.spritesPerRow")
36
- assert(self._options.spriteSize, "Bad options.spriteSize")
37
- assert(self._options.framesPerSecond, "Bad options.framesPerSecond")
38
-
39
- for i=0, options.frames do
40
- local x = i % options.spritesPerRow
41
- local y = math.floor(i / options.spritesPerRow)
42
- local position = options.spriteSize*Vector2.new(x, y)
43
-
44
- self:AddSprite(i + 1, position, options.spriteSize)
45
- end
46
-
47
- return self
48
- end
49
-
50
- --[=[
51
- Gets the sprite size
52
- @return Vector2
53
- ]=]
54
- function AnimatedSpritesheet:GetSpriteSize()
55
- return self._options.spriteSize
56
- end
57
-
58
- --[=[
59
- Gets the frames per a second
60
- @return number
61
- ]=]
62
- function AnimatedSpritesheet:GetFramesPerSecond()
63
- return self._options.framesPerSecond
64
- end
65
-
66
- --[=[
67
- Gets the play time for the animated sheet
68
- @return number
69
- ]=]
70
- function AnimatedSpritesheet:GetPlayTime()
71
- return self._options.frames/self._options.framesPerSecond
72
- end
73
-
74
- --[=[
75
- Retrieves the frames for the sprite sheet.
76
- @return frames
77
- ]=]
78
- function AnimatedSpritesheet:GetFrames()
79
- return self._options.frames
80
- end
81
-
82
- return AnimatedSpritesheet
@@ -1,61 +0,0 @@
1
- --[[
2
- @class AnimatedSpritesheet.story
3
- ]]
4
-
5
- local require = require(game:GetService("ServerScriptService"):FindFirstChild("LoaderUtils", true).Parent).load(script)
6
-
7
- local AnimatedSpritesheet = require("AnimatedSpritesheet")
8
- local AnimatedSpritesheetPlayer = require("AnimatedSpritesheetPlayer")
9
- local Maid = require("Maid")
10
- local UICornerUtils = require("UICornerUtils")
11
-
12
- local function makeLabel(maid, sheet, target)
13
- local size = sheet:GetSpriteSize()
14
-
15
- local imageLabel = Instance.new("ImageLabel")
16
- imageLabel.BackgroundTransparency = 0
17
- imageLabel.BackgroundColor3 = Color3.new(0.5, 0.5, 0.5)
18
- imageLabel.Size = UDim2.fromOffset(size.x, size.y)
19
- imageLabel.BorderSizePixel = 0
20
- maid:GiveTask(imageLabel)
21
-
22
- UICornerUtils.fromOffset(8, imageLabel)
23
-
24
- local player = AnimatedSpritesheetPlayer.new(imageLabel, sheet)
25
- maid:GiveTask(player)
26
-
27
- imageLabel.Parent = target
28
-
29
- return imageLabel
30
- end
31
-
32
- return function(target)
33
- local maid = Maid.new()
34
-
35
- local container = Instance.new("Frame")
36
- container.Size = UDim2.new(1, 0, 1, 0)
37
- container.BackgroundTransparency = 0
38
- container.BackgroundColor3 = Color3.new(0, 0, 0)
39
- container.Parent = target
40
- maid:GiveTask(container)
41
-
42
- local uiListLayout = Instance.new("UIListLayout")
43
- uiListLayout.FillDirection = Enum.FillDirection.Horizontal
44
- uiListLayout.VerticalAlignment = Enum.VerticalAlignment.Center
45
- uiListLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center
46
- uiListLayout.Padding = UDim.new(0, 10)
47
- uiListLayout.SortOrder = Enum.SortOrder.LayoutOrder
48
- uiListLayout.Parent = container
49
-
50
- makeLabel(maid, AnimatedSpritesheet.new({
51
- texture = "rbxassetid://5085366281";
52
- frames = 34;
53
- spritesPerRow = 6;
54
- spriteSize = Vector2.new(85.33333, 85.33333);
55
- framesPerSecond = 30;
56
- }), container)
57
-
58
- return function()
59
- maid:DoCleaning()
60
- end
61
- end
@@ -1,60 +0,0 @@
1
- --[=[
2
- Plays an [AnimatedSpritesheet] for an given image label.
3
- @class AnimatedSpritesheetPlayer
4
- ]=]
5
-
6
- local require = require(script.Parent.loader).load(script)
7
-
8
- local RunService = game:GetService("RunService")
9
-
10
- local BaseObject = require("BaseObject")
11
- local Maid = require("Maid")
12
-
13
- local AnimatedSpritesheetPlayer = setmetatable({}, BaseObject)
14
- AnimatedSpritesheetPlayer.ClassName = "AnimatedSpritesheetPlayer"
15
- AnimatedSpritesheetPlayer.__index = AnimatedSpritesheetPlayer
16
-
17
- --[=[
18
- Constructs a new AnimatedSpritesheetPlayer
19
- @param imageLabel ImageLabel
20
- @param spritesheet AnimatedSpritesheet?
21
- @return AnimatedSpritesheetPlayer
22
- ]=]
23
- function AnimatedSpritesheetPlayer.new(imageLabel, spritesheet)
24
- local self = setmetatable(BaseObject.new(spritesheet), AnimatedSpritesheetPlayer)
25
-
26
- self._imageLabel = assert(imageLabel, "Bad imageLabel")
27
-
28
- if spritesheet then
29
- self:SetSheet(spritesheet)
30
- end
31
-
32
- return self
33
- end
34
-
35
- --[=[
36
- Sets the current sheet and starts play if needed
37
- @param spritesheet AnimatedSpritesheet
38
- ]=]
39
- function AnimatedSpritesheetPlayer:SetSheet(spritesheet)
40
- assert(spritesheet, "Bad spritesheet")
41
-
42
- self._spritesheet = spritesheet
43
- self:_play()
44
- end
45
-
46
- function AnimatedSpritesheetPlayer:_play()
47
- local maid = Maid.new()
48
-
49
- local fps = self._spritesheet:GetFramesPerSecond()
50
- local frames = self._spritesheet:GetFrames()
51
-
52
- maid:GiveTask(RunService.RenderStepped:Connect(function()
53
- local frame = (math.floor(tick()*fps)%frames)+1
54
- self._spritesheet:GetSprite(frame):Style(self._imageLabel)
55
- end))
56
-
57
- self._maid._play = maid
58
- end
59
-
60
- return AnimatedSpritesheetPlayer