Spritesheet - how to use with initWithFile

I am using js.

this.icons = new IconsSprites();

this.icons.displayObjects('res/icon_1.png');

var IconsSprites = cc.Sprite.extend({
    ctor: function() {
	this._super();
    },
    displayObjects: function(image) {
		this.setOpacity(0);
		this.initWithFile(image);
		//this.setPosition(cc.p(xLocation, yLocation));
		this.setAnchorPoint(0.5, 0.5);
		//this.setRotation(cc.p(rotation));

		var actionFadeIn = new cc.FadeIn(.2);
		this.runAction(actionFadeIn);
	}

The above code is working.

But if i use

this.icons.displayObjects(this.spriteFrameCacheGameIcons.getSpriteFrame("instructions.png"));

It is not working. It throws error.
Please help how to fix this error

Failed to load resource: the server responded with a status of 404 (File not found) http://127.0.0.1:8000/[object%20Object]

@agriz,

Can you Try with

initWithSpriteFrameName(“instructions.png”)

Regards,
Gurudath

1 Like