Uncaught TypeError: setTextureRect is not a function

Working with sprites and textures, when I use the setTextureRect() function (e.g. mySprite.setTextureRect(cc.Rect(0, 0, w, h));) I get the error:

Uncaught TypeError: mySprite.setTextureRect is not a function

Where am I going wrong?
Many thanks,
Dom

That function is not in the API of Cocos Creator.

You can check Cocos Creator API here:
http://cocos2d-x.org/docs/api-ref/creator/v0.71/

By the way, you can edit all the properties of your sprite directly with Cocos Creator.


Daniel

You are right…I was using the js api reference.
Many thanks,
Dom

Can you show me, snip code to do setTextureRect() in creator please!

spriteFrame.setRect(new cc.Rect(x, y, width, height))

It’s worked, but just once. How can I run this at update loop?