objective c - How to crop two images and splice into one in iOS Sprite Kit? -


i developing game appstore in xcode's sprite kit. have single colored shapes want 'splice' one, , have user able drag , drop spliced image single colored shapes.

in more detail: have following 2 images: http://s1381.photobucket.com/user/shahmeen/media/circleyellow_zps11feede7.png.html http://s1381.photobucket.com/user/shahmeen/media/circlered_zps49eb1802.png.html

skspritenode *spritea; spritea = [skspritenode spritenodewithimagenamed:@"circleyellow"]; [self addchild:spritea]; skspritenode *spriteb; spriteb = [skspritenode spritenodewithimagenamed:@"circlered"]; [self addchild:spriteb]; 

i have third sprite, looks below (forgive me crude photoshop skills ... if links aren't working, want create image, spritec, left half of being left half of spritea , right half of being right half of spriteb): http://s1381.photobucket.com/user/shahmeen/media/circlered_zps9ca710cb.png.html

(some code crops spritea , spriteb , then) skspritenode *spritec; spritec = (the output of spritea , spriteb cropped , spliced together); [self addchild:spritec]; 

i know can using skshapenodes simplicity of objects above, intend more complex figures. don't think practical me load in several .pngs because i'll getting several hundreds count permutations. i'll happy clarify - thanks

i create final combination of 2 images code , make skspritenode use combined image texture. can follows, assuming 2 images & final 1 have same size:

- (uiimage*)combineimage:(uiimage*)leftimage withimage:(uiimage*)rightimage{     cgsize finalimagesize = leftimage.size;     cgfloat scale = leftimage.scale;      uigraphicsbeginimagecontextwithoptions(finalimagesize, no, scale);     cgcontextref context = uigraphicsgetcurrentcontext();      [leftimage drawatpoint:cgpointzero];     cgcontextcliptorect(context, cgrectmake(finalimagesize.width/2, 0, finalimagesize.width/2, finalimagesize.height)); //use cliptomask maskimage if have more complicated images     [rightimage drawatpoint:cgpointzero];     uiimage *image = uigraphicsgetimagefromcurrentimagecontext();     uigraphicsendimagecontext();      return image; } 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -