Sprites from texture

Coming from an XNA background I’m finding the documentation hard to follow for someone not familiar with this framework so I’d appreciate some help here. After struggling for two days to get cocos2d-x 2.2.1 working with WP8, and finally succeeding, I am now attempting to figure out some basic sprite processing stuff. What I want to do is to create a CCSprite using image data from a larger image, 508x675 pixels. Each tile is 508x75 pixels, e.g. 9 tiles total stacked vertically.

The API reference seems to indicate CCTexture2D would be good for this purpose so this is what I tried:

//Load image containing all 9 tiles
CCImage *tileSheet = new CCImage();
tileSheet->initWithImageFile("tilesheet.png");

//Init the texture with image
CCTexture2D *tileTex = new CCTexture2D();
tileTex->initWithImage(tileSheet);

//Assign first (top) tile to tileSprite(?)
CCSprite* tileSprite = new CCSprite();
tileSprite->initWithTexture(tileTex, CCRectMake(0,0,508,75));

//Draw it
tileSprite->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));

this->addChild(tileSprite, 0);

The result is not what I expected. Instead of drawing the top tile there are parts of other tiles drawn as well. Obviously I’m missing some information here as tileSprite->initWithTexture does not appear to do what I want. Any pointers to what am I doing wrong?

Ok, so in case anyone is interested I think I figured it out. The “problem” was in AppDelegate.cpp, pDirector->setContentScaleFactor which apparently scales everything. The following code modification made it work exactly as expected:

...
//Get scale factor before copying tile
CCDirector* pDirector = CCDirector::sharedDirector();
float sf = pDirector->getContentScaleFactor();

//Assign first (top) tile to tileSprite(?)
CCSprite* tileSprite = new CCSprite();
tileSprite->initWithTexture(tileTex, CCRectMake(0,0,508/sf,75/sf));

//Draw it
...