Skip to main content
Participating Frequently
August 26, 2021
Question

How to use a sprite sheet from Library instead from file?

  • August 26, 2021
  • 2 replies
  • 839 views

I'm more interested in making interactive animations in An using coding with CreateJS and I have to admit that more complex things aren't very clear to me, I guess because I couldn't find a book that really covers that area. From the official site of CreateJS, I copied the code of an animation in which the character of a little man runs across a meadow and with a few modifications, it really works in An. However, I'd rather know how to edit the manifest declaration so that in addition to some images it reads from the directory (here from / art) it takes a sprite / sprite sheet directly from the Library based on the name in the Linkage column (in my case the Linkage name is GRUNT). Is it possible to make it? Thank you very much for the answer.

manifest = [
		{src: new lib.GRUNT, id: "grant"}, //this one does not work
		{src: "sky.png", id: "sky"},
		{src: "ground.png", id: "ground"},
		{src: "hill1.png", id: "hill"},
		{src: "hill2.png", id: "hill2"}
	];

 

This topic has been closed for replies.

2 replies

Legend
August 26, 2021

Do NOT try to stick your fingers into the manifest, or any of the code Animate generates when you publish. That will bring you nothing but trouble, unless you really, really know what you're doing. Any assets you want to use, import them into the library like a normal person. They will automatically be included in the manifest, as long as they're used at least once somewhere on the timeline, or have a linkage name.

Lehi5EF3Author
Participating Frequently
August 28, 2021

Hi, it seems like we did not understand each other: I do not plan to change anything in Animate output code, I just wish to load my sprite sheet from disc into Animate library and reference it in my CreateJS code (by Linkage name from Library) instead to load sprite sheet from disc as a PNG file.  Code is here, the part "images" is the place where I would like to implement sprite sheet linkage name insted to use loader and LoadQueue:

var spriteSheet = new createjs.SpriteSheet({
			framerate:24, //bilo 30
			"images": [loader.getResult("grant")],
			"frames": {"regX": 82, "height": 292, "count": 64, "regY": 0, "width": 165},
			// define two animations, run (loops, 1.5x speed) and jump (returns to run):
			"animations": {
				"run": [0, 25, "run", 1.5],
				"jump": [26, 63, "run"]
			}
		});
	grant = new createjs.Sprite(spriteSheet, "run");
	grant.y = 35;
Legend
August 28, 2021

You said you wanted to edit the manifest. The manifest is part of the output code. Now you're saying you don't want to edit the output code. So you don't want to edit the manifest.

kglad
Community Expert
Community Expert
August 26, 2021

i don't understand your question.  you want to export a sprite sheet from animate (or somewhere else) and then you want to import that sprite sheet back into the animate library and use it from there?  and you want to do all that by editing the manifest>?

Lehi5EF3Author
Participating Frequently
August 26, 2021

Hello kglad... thanks for stopping by. No, I have working .fla where all images, including sprite sheet called  spritesheet_grant.png are in local directory called /art and it works fine. I try to put all files mentioned in manifest [] (or just the sprite sheet spritesheet_grant.png ) into An Library and use them directly from Library based on their Linkage name, like GRUNT. Earlier I was able to make some symbol and add to Library, linkage name (ROCKET) and then also I was able to use it like:

var myRocket = new lib.ROCKET, so I thought i could use same ide here. In meantime I tried to exclude sprite sheet from manifest[] and use this code to "catch" sprite sheet:

var spriteSheet = new createjs.SpriteSheet({
			framerate: 30,
			"images": [GRUNT],
			"frames": {"regX": 82, "height": 292, "count": 64, "regY": 0, "width": 165},
			// define two animations, run (loops, 1.5x speed) and jump (returns to run):
			"animations": {
				"run": [0, 25, "run", 1.5],
				"jump": [26, 63, "run"]
			}
		});
	grant = new createjs.Sprite(spriteSheet, "run");
	grant.y = 35;

but it doesn't work.