Reputation: 287
I used setContentSize
but it doesn't work. And I don't want to scale stuff in the layer so I won't use setScale
.
What should I do?
Upvotes: 1
Views: 5001
Reputation: 4132
Maybe?
auto layerInstance = LayerColor::create();
auto layerInstanceSize = layerInstance->getContentSize();
float layerInstanceSizeWidth = layerInstanceSize.width;
float layerInstanceSizeHeight = layerInstanceSize.height;
Upvotes: 0
Reputation: 14009
setContentSize should work as the following. How did you do that?
CCLayerGradient* layer1 = CCLayerGradient::create(ccc4(255, 0, 0, 255), ccc4(255, 0, 255, 255));
layer1->setContentSize(CCSizeMake(80, 80));
EDITED
So you mean you want to clip the image by the content size of the layer? Try to use CCClippingNode
or this glScissor node example.
Upvotes: 2
Reputation: 427
Try! this it works for me.
CCSize screenSize = CCDirector::sharedDirector()->getVisibleSize();
float x = screenSize.width;
float y = screenSize.height;
CCLayer* layer = new MyLayer();
float layerX = layer->getContentSize().width;
float layerY= layer->getContentSize().height;
float scaleX = x/layerX;
float scaleY = y/layerY;
layer->setScaleX(scaleX*1.2f);
layer->setScaleY(scaleY*1.2f);
Upvotes: 0