What is getContentSize() ? Everything about it. Why we use it when setting position of sprite with setPosition function ?
How To Make Flappy Bird-
VineetLikes 0Problem Description
Hi !
In this tutorial – Creating Pipe Class Video # 7.
auto topPipePosition = ( random * visible.height ) + ( pipe->getContentSize().height/2 );
// What is this doing here –> ( pipe->getContentSize().height/2 ). Why have we added it ?
Thank You
-
Sonar Systems adminLikes 0
getContentSize gets the physical size of the sprite including alpha. We use it to help us position our items according to their size.
-
VineetLikes 0
I have a sprite. The pipe sprite. It’s size is – 150 x 1000 pixels. I made it. But When I run CCLOG(“SIZE :”, pipe->getContentSize().height); or CCLOG(“SIZE :”, pipe->getContentSize().width); It’s neither of the width or height as shown by image detials.
And you just said – You use it to position sprite. I would appreciate if you explain a litttle in detail the positioning using getContentSize. You can use the above example for setting pipe position. What is happeneing there ?
-
Sonar Systems adminLikes 0
What numbers do you get?
-
VineetLikes 0
The image size is 250 x 250 pixels. But results are = 57.28….something. I haven’t yet applied any transformation.
-
Sonar Systems adminLikes 0
Can you show us the code in your AppDelegate.cpp
Login to reply