Multiple parties are very powerful and can meet the needs of many different time points. When the image size is not the required size, you should use scaling to meet your needs. The scaling factor = the required size/original image size;
As follows:
; CCSize size = CCDirector: sharedDirector ()-> getWinSize (); CCSprite * CCSprite: create (". /Images/menu/ingamepig.png "); //, CCRectMake (800,480,); CC_BREAK_IF (! BackGround); float scalX = size. width/backGround-> getContentSize (). width; // set the scale factor float scalY = size in the X axis direction. height/backGround-> getContentSize (). height; // set the backGround-> setScaleX (scalX); backGround-> setScaleY (scalY); backGround-> setPosition (ccp (size. width/2, size. height/2); this-> addChild (backGround, 0, 0 );
Original Image Size
650) this. width = 650; "src ="/e/u/themes/default/images/spacer.gif "word_img =" file: // C: \ Users \ john \ AppData \ Roaming \ Tencent \ Users \ 1617176084 \ QQ \ WinTemp \ RichOle \ 4TW ~ S6%xnk'qt%uz%q9v4np.jpg "style =" url (/e/u/lang/zh-cn/images/localimage.png) no-repeat center; border: 1px solid # ddd "/> 650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/2053045143-0.png "title =" .png "/>
Scaled Image
650) this. width = 650; "src =" http://img1.51cto.com/attachment/201308/115203769.png "title =" scaled image .png "/>