I encountered a problem in [login to view URL] game development.
I'm going to create new one sprite by combining same sprites with different offsets.
I work on cocos creator v.2.0.0
My basic code is as follows. Of course it is not work correctly.
..........................
var spriteUrl = "texture/brush";
var spriteOffsets = {
[login to view URL](5, 7),
[login to view URL](8, 10),
...
}
...
[login to view URL](spriteOffsets );
...
createOneSpriteWithdifferentOffsets(spriteOffsets ) {
var canvas, context, texture;
canvas = [login to view URL]('canvas');
[login to view URL] = max-width of offsets;
[login to view URL] = max-height of offsets;
context = [login to view URL]('2d');
for(var i = 0; i < spriteOffsets .length; i++){
context .drawImage(spriteUrl, spriteOffsets[i]);
}
texture = new [login to view URL]();
[login to view URL](canvas);
[login to view URL]();
let spriteFrame = new [login to view URL]();
[login to view URL](texture);
let node = new [login to view URL]();
let sprite = [login to view URL]([login to view URL]);
[login to view URL] = spriteFrame;
return node;
}
For more, see example.png.
I want to complete my idea as possible as quickly.