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();
//Init the texture with image
CCTexture2D *tileTex = new CCTexture2D();
//Assign first (top) tile to tileSprite(?)
CCSprite* tileSprite = new CCSprite();
tileSprite->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
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?