objective c - Access a website when tapping an image in cocos2d -
i making app using cocos2d using images display data. want make display image "link". so, when user taps image, opens particular website. using cocos2d , objective-c first time. don't know how proceed this
any appreciated.
thanks!
try this:
-(void)createimagebutton { ccsprite *image_1 = [ccsprite spritewithfile:@"image_1.png"]; ccsprite *image_2 = [ccsprite spritewithfile:@"image_2.png"]; ccmenuitemsprite *imagebtn = [ccmenuitemsprite itemfromnormalsprite: image_1 selectedsprite:image_2 target:self selector:@selector(imagebtnpress:) ]; imagebtn.position = ccp(width*0.5f, height*0.5f); ccmenu *menu = [ccmenu menuwithitems: imagebtn, nil]; menu.position = ccp(0.0f, 0.0f); [self addchild: menu z:100]; } -(void) imagebtnpress:(id)sender { //here open website link [[uiapplication sharedapplication] openurl:[nsurl urlwithstring:@"http://www.apple.com"]]; }
Comments
Post a Comment