Problem with SpriteFrame HELP

Problem with SpriteFrame HELP
0.0 0


I cant not see the sprite when I create it from a SpriteFrame. I cant found the problem. All look fine, not error only this log: “function webkitRequestAnimationFrame() { [native code] }”

    var CLOCK_RECT = new cc.Rect(0,0,33,37); // image size 

    var texture = textureCache.addImage(frameName);
    var frame = cc.SpriteFrame.frameWithTexture(texture, CLOCK_RECT);

    // create the object
    this.clock = cc.Sprite.spriteWithSpriteFrameName(frameName);


I cant found the problem but found the solution. What is the problem ? The texture reference change is Size ? This is really strange.

frameName = "Resources/filename.png"; // png w:32:h:36
texture = textureCache.addImage(frameName);

var CLOCK_RECT = new cc.Rect(0,0,32,36);

// this line dont work !!!!
//CLOCK_RECT.size = cc.SizeMake(32,36); 
// This line work !!! 
CLOCK_RECT.size = cc.SizeMake(texture.width, texture.height); //texture.width = 32 texture.height = 36

frame = cc.SpriteFrame.frameWithTexture(texture,CLOCK_RECT);


Did you preload your resources?

If no, it will be wrong when it is drew with given width and height.

Please make sure you have preloaded the resources before you use them.


Yes, I was preload all assets. And Width and Height are fine when set the frame.

I do this and don’t work.

//CLOCK_RECT.size = cc.SizeMake(32,36); 

I do this and work

CLOCK_RECT.size = cc.SizeMake(texture.width, texture.height); //texture.width = 32 texture.height = 36 in log.

Maybe the problem is in other place, I don’t know.

Thanks for the response.