Scaling images / sprites to the body scale
Posted: Tue Apr 30, 2013 12:12 pm
I'm using RUBE to draw a polygon around an image, and exporting it to my program. There I create a CCSprite and work with it in Android. So far so good.
Now, I need to have a larger car in my program. So I go to RUBE, drop the car image onto the scene, draw the body polygon, and then scale it to my desired size. But in my program, the image is still the same size, so I get a "ghost" care around my car image.
So the question is, how do I sale the image? Or in cocos2d terms, how do I scale the sprite?
For quick reference, this is how I create the sprite:
CCSprite sprite = CCSprite.sprite(imageName);
layer.addChild(sprite, 0);
body.setUserData(sprite);
So I'm looking for something like:
sprite.scaleTo(body.getScale());
Now, I need to have a larger car in my program. So I go to RUBE, drop the car image onto the scene, draw the body polygon, and then scale it to my desired size. But in my program, the image is still the same size, so I get a "ghost" care around my car image.
So the question is, how do I sale the image? Or in cocos2d terms, how do I scale the sprite?
For quick reference, this is how I create the sprite:
CCSprite sprite = CCSprite.sprite(imageName);
layer.addChild(sprite, 0);
body.setUserData(sprite);
So I'm looking for something like:
sprite.scaleTo(body.getScale());