Skip to content

Commit 6a3280b

Browse files
committed
Added Texture.getFramesFromTextureSource and Texture.getTextureSourceIndex from a TextureSource.
1 parent d7bd14b commit 6a3280b

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

v3/src/textures/Texture.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,42 @@ var Texture = new Class({
9393
}
9494
},
9595

96+
getTextureSourceIndex: function (source)
97+
{
98+
for (var i = 0; i < this.source.length; i++)
99+
{
100+
if (this.source[i] === source)
101+
{
102+
return i;
103+
}
104+
}
105+
106+
return -1;
107+
},
108+
109+
// source = TextureSource object
110+
getFramesFromTextureSource: function (sourceIndex)
111+
{
112+
var out = [];
113+
114+
for (var frameName in this.frames)
115+
{
116+
if (frameName === '__BASE')
117+
{
118+
continue;
119+
}
120+
121+
var frame = this.frames[frameName];
122+
123+
if (frame.sourceIndex === sourceIndex)
124+
{
125+
out.push(frame.name);
126+
}
127+
}
128+
129+
return out;
130+
},
131+
96132
getFrameNames: function (includeBase)
97133
{
98134
if (includeBase === undefined) { includeBase = false; }

0 commit comments

Comments
 (0)