• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Explorer ,
Aug 26, 2021 Aug 26, 2021

Copy link to clipboard

Copied

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"}
	];

 

TOPICS
Code , How to

Views

210

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 26, 2021 Aug 26, 2021

Copy link to clipboard

Copied

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>?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 26, 2021 Aug 26, 2021

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 26, 2021 Aug 26, 2021

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 28, 2021 Aug 28, 2021

Copy link to clipboard

Copied

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;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 28, 2021 Aug 28, 2021

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines