CCDevice-ios.mm 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. /****************************************************************************
  2. Copyright (c) 2010-2012 cocos2d-x.org
  3. Copyright (c) 2013-2017 Chukong Technologies Inc.
  4. http://www.cocos2d-x.org
  5. Permission is hereby granted, free of charge, to any person obtaining a copy
  6. of this software and associated documentation files (the "Software"), to deal
  7. in the Software without restriction, including without limitation the rights
  8. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the Software is
  10. furnished to do so, subject to the following conditions:
  11. The above copyright notice and this permission notice shall be included in
  12. all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. THE SOFTWARE.
  20. ****************************************************************************/
  21. #include "platform/CCPlatformConfig.h"
  22. #if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
  23. #include "platform/CCDevice.h"
  24. #include "base/ccTypes.h"
  25. #include "platform/apple/CCDevice-apple.h"
  26. #include "base/CCEventDispatcher.h"
  27. #include "base/CCEventAcceleration.h"
  28. #include "base/CCDirector.h"
  29. #import <UIKit/UIKit.h>
  30. // Accelerometer
  31. #if !defined(CC_TARGET_OS_TVOS)
  32. #import<CoreMotion/CoreMotion.h>
  33. #endif
  34. #import<CoreFoundation/CoreFoundation.h>
  35. #import <CoreText/CoreText.h>
  36. // Vibrate
  37. #import <AudioToolbox/AudioToolbox.h>
  38. static NSAttributedString* __attributedStringWithFontSize(NSMutableAttributedString* attributedString, CGFloat fontSize)
  39. {
  40. {
  41. [attributedString beginEditing];
  42. [attributedString enumerateAttribute:NSFontAttributeName inRange:NSMakeRange(0, attributedString.length) options:0 usingBlock:^(id value, NSRange range, BOOL *stop) {
  43. UIFont* font = value;
  44. font = [font fontWithSize:fontSize];
  45. [attributedString removeAttribute:NSFontAttributeName range:range];
  46. [attributedString addAttribute:NSFontAttributeName value:font range:range];
  47. }];
  48. [attributedString endEditing];
  49. }
  50. return [[attributedString copy] autorelease];
  51. }
  52. static CGFloat _calculateTextDrawStartHeight(cocos2d::Device::TextAlign align, CGSize realDimensions, CGSize dimensions)
  53. {
  54. float startH = 0;
  55. // vertical alignment
  56. unsigned int vAlignment = ((int)align >> 4) & 0x0F;
  57. switch (vAlignment) {
  58. //bottom
  59. case 2:startH = dimensions.height - realDimensions.height;break;
  60. //top
  61. case 1:startH = 0;break;
  62. //center
  63. case 3: startH = (dimensions.height - realDimensions.height) / 2;break;
  64. default:
  65. break;
  66. }
  67. return startH;
  68. }
  69. static CGSize _calculateShrinkedSizeForString(NSAttributedString **str, id font, CGSize constrainSize, bool enableWrap, int& newFontSize)
  70. {
  71. CGRect actualSize = CGRectMake(0, 0, constrainSize.width + 1, constrainSize.height + 1);
  72. int fontSize = [font pointSize];
  73. fontSize = fontSize + 1;
  74. if (!enableWrap) {
  75. while (actualSize.size.width > constrainSize.width ||
  76. actualSize.size.height > constrainSize.height) {
  77. fontSize = fontSize - 1;
  78. if(fontSize < 0) {
  79. actualSize = CGRectMake(0, 0, 0, 0);
  80. break;
  81. }
  82. NSMutableAttributedString *mutableString = [[*str mutableCopy] autorelease];
  83. *str = __attributedStringWithFontSize(mutableString, fontSize);
  84. CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString((__bridge CFAttributedStringRef)*str);
  85. CGSize targetSize = CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX);
  86. CGSize fitSize = CTFramesetterSuggestFrameSizeWithConstraints(framesetter, CFRangeMake(0, [(*str) length]), NULL, targetSize, NULL);
  87. CFRelease(framesetter);
  88. if (fitSize.width == 0 || fitSize.height == 0) {
  89. continue;
  90. }
  91. actualSize.size = fitSize;
  92. if (constrainSize.width <= 0) {
  93. constrainSize.width = fitSize.width;
  94. }
  95. if (constrainSize.height <= 0) {
  96. constrainSize.height = fitSize.height;
  97. }
  98. if (fontSize <= 0) {
  99. break;
  100. }
  101. }
  102. }
  103. else {
  104. while (actualSize.size.height > constrainSize.height ||
  105. actualSize.size.width > constrainSize.width) {
  106. fontSize = fontSize - 1;
  107. if(fontSize < 0) {
  108. actualSize = CGRectMake(0, 0, 0, 0);
  109. break;
  110. }
  111. NSMutableAttributedString *mutableString = [[*str mutableCopy] autorelease];
  112. *str = __attributedStringWithFontSize(mutableString, fontSize);
  113. CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString((__bridge CFAttributedStringRef)*str);
  114. CGSize targetSize = CGSizeMake(constrainSize.width, CGFLOAT_MAX);
  115. CGSize fitSize = CTFramesetterSuggestFrameSizeWithConstraints(framesetter, CFRangeMake(0, [(*str) length]), NULL, targetSize, NULL);
  116. CFRelease(framesetter);
  117. if (fitSize.width == 0 || fitSize.height == 0) {
  118. continue;
  119. }
  120. actualSize.size = fitSize;
  121. if (constrainSize.height <= 0) {
  122. constrainSize.height = fitSize.height;
  123. }
  124. if (constrainSize.width <= 0) {
  125. constrainSize.width = fitSize.width;
  126. }
  127. if (fontSize <= 0) {
  128. break;
  129. }
  130. }
  131. }
  132. newFontSize = fontSize;
  133. return CGSizeMake(actualSize.size.width, actualSize.size.height);
  134. }
  135. #define SENSOR_DELAY_GAME 0.02
  136. #if !defined(CC_TARGET_OS_TVOS)
  137. @interface CCAccelerometerDispatcher : NSObject<UIAccelerometerDelegate>
  138. {
  139. cocos2d::Acceleration *_acceleration;
  140. CMMotionManager *_motionManager;
  141. }
  142. + (id) sharedAccelerometerDispatcher;
  143. - (id) init;
  144. - (void) setAccelerometerEnabled: (bool) isEnabled;
  145. - (void) setAccelerometerInterval:(float) interval;
  146. @end
  147. @implementation CCAccelerometerDispatcher
  148. static CCAccelerometerDispatcher* s_pAccelerometerDispatcher;
  149. + (id) sharedAccelerometerDispatcher
  150. {
  151. if (s_pAccelerometerDispatcher == nil) {
  152. s_pAccelerometerDispatcher = [[self alloc] init];
  153. }
  154. return s_pAccelerometerDispatcher;
  155. }
  156. - (id) init
  157. {
  158. if( (self = [super init]) ) {
  159. _acceleration = new (std::nothrow) cocos2d::Acceleration();
  160. _motionManager = [[CMMotionManager alloc] init];
  161. _motionManager.accelerometerUpdateInterval = SENSOR_DELAY_GAME;
  162. }
  163. return self;
  164. }
  165. - (void) dealloc
  166. {
  167. s_pAccelerometerDispatcher = nullptr;
  168. delete _acceleration;
  169. [_motionManager release];
  170. [super dealloc];
  171. }
  172. - (void) setAccelerometerEnabled: (bool) isEnabled
  173. {
  174. if (isEnabled)
  175. {
  176. [_motionManager startAccelerometerUpdatesToQueue:[NSOperationQueue currentQueue] withHandler:^(CMAccelerometerData *accelerometerData, NSError *error) {
  177. [self accelerometer:accelerometerData];
  178. }];
  179. }
  180. else
  181. {
  182. [_motionManager stopAccelerometerUpdates];
  183. }
  184. }
  185. -(void) setAccelerometerInterval:(float)interval
  186. {
  187. _motionManager.accelerometerUpdateInterval = interval;
  188. }
  189. - (void)accelerometer:(CMAccelerometerData *)accelerometerData
  190. {
  191. _acceleration->x = accelerometerData.acceleration.x;
  192. _acceleration->y = accelerometerData.acceleration.y;
  193. _acceleration->z = accelerometerData.acceleration.z;
  194. _acceleration->timestamp = accelerometerData.timestamp;
  195. double tmp = _acceleration->x;
  196. switch ([[UIApplication sharedApplication] statusBarOrientation])
  197. {
  198. case UIInterfaceOrientationLandscapeRight:
  199. _acceleration->x = -_acceleration->y;
  200. _acceleration->y = tmp;
  201. break;
  202. case UIInterfaceOrientationLandscapeLeft:
  203. _acceleration->x = _acceleration->y;
  204. _acceleration->y = -tmp;
  205. break;
  206. case UIInterfaceOrientationPortraitUpsideDown:
  207. _acceleration->x = -_acceleration->y;
  208. _acceleration->y = -tmp;
  209. break;
  210. case UIInterfaceOrientationPortrait:
  211. break;
  212. default:
  213. NSAssert(false, @"unknown orientation");
  214. }
  215. cocos2d::EventAcceleration event(*_acceleration);
  216. auto dispatcher = cocos2d::Director::getInstance()->getEventDispatcher();
  217. dispatcher->dispatchEvent(&event);
  218. }
  219. @end
  220. #endif // !defined(CC_TARGET_OS_TVOS)
  221. //
  222. NS_CC_BEGIN
  223. int Device::getDPI()
  224. {
  225. static int dpi = -1;
  226. if (dpi == -1)
  227. {
  228. float scale = 1.0f;
  229. if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
  230. scale = [[UIScreen mainScreen] scale];
  231. }
  232. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
  233. dpi = 132 * scale;
  234. } else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
  235. dpi = 163 * scale;
  236. } else {
  237. dpi = 160 * scale;
  238. }
  239. }
  240. return dpi;
  241. }
  242. void Device::setAccelerometerEnabled(bool isEnabled)
  243. {
  244. #if !defined(CC_TARGET_OS_TVOS)
  245. [[CCAccelerometerDispatcher sharedAccelerometerDispatcher] setAccelerometerEnabled:isEnabled];
  246. #endif
  247. }
  248. void Device::setAccelerometerInterval(float interval)
  249. {
  250. #if !defined(CC_TARGET_OS_TVOS)
  251. [[CCAccelerometerDispatcher sharedAccelerometerDispatcher] setAccelerometerInterval:interval];
  252. #endif
  253. }
  254. typedef struct
  255. {
  256. unsigned int height;
  257. unsigned int width;
  258. bool isPremultipliedAlpha;
  259. bool hasShadow;
  260. CGSize shadowOffset;
  261. float shadowBlur;
  262. float shadowOpacity;
  263. bool hasStroke;
  264. float strokeColorR;
  265. float strokeColorG;
  266. float strokeColorB;
  267. float strokeColorA;
  268. float strokeSize;
  269. float tintColorR;
  270. float tintColorG;
  271. float tintColorB;
  272. float tintColorA;
  273. unsigned char* data;
  274. } tImageInfo;
  275. static CGSize _calculateStringSize(NSAttributedString *str, id font, CGSize *constrainSize, bool enableWrap, int overflow)
  276. {
  277. CGSize textRect = CGSizeZero;
  278. textRect.width = constrainSize->width > 0 ? constrainSize->width
  279. : CGFLOAT_MAX;
  280. textRect.height = constrainSize->height > 0 ? constrainSize->height
  281. : CGFLOAT_MAX;
  282. if (overflow == 1) {
  283. if(!enableWrap) {
  284. textRect.width = CGFLOAT_MAX;
  285. textRect.height = CGFLOAT_MAX;
  286. } else {
  287. textRect.height = CGFLOAT_MAX;
  288. }
  289. }
  290. CGSize dim;
  291. dim = [str boundingRectWithSize:CGSizeMake(textRect.width, textRect.height)
  292. options:(NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading)
  293. context:nil].size;
  294. dim.width = ceilf(dim.width);
  295. dim.height = ceilf(dim.height);
  296. return dim;
  297. }
  298. static id _createSystemFont( const char * fontName, int size)
  299. {
  300. NSString * fntName = [NSString stringWithUTF8String:fontName];
  301. // On iOS custom fonts must be listed beforehand in the App info.plist (in order to be usable) and referenced only the by the font family name itself when
  302. // calling [UIFont fontWithName]. Therefore even if the developer adds 'SomeFont.ttf' or 'fonts/SomeFont.ttf' to the App .plist, the font must
  303. // be referenced as 'SomeFont' when calling [UIFont fontWithName]. Hence we strip out the folder path components and the extension here in order to get just
  304. // the font family name itself. This stripping step is required especially for references to user fonts stored in CCB files; CCB files appear to store
  305. // the '.ttf' extensions when referring to custom fonts.
  306. fntName = [[fntName lastPathComponent] stringByDeletingPathExtension];
  307. // create the font
  308. id font = [UIFont fontWithName:fntName size:size];
  309. if (!font)
  310. {
  311. font = [UIFont systemFontOfSize:size];
  312. }
  313. return font;
  314. }
  315. static bool _initWithString(const char * text, cocos2d::Device::TextAlign align, const char * fontName, int size, tImageInfo* info, bool enableWrap, int overflow)
  316. {
  317. bool bRet = false;
  318. do
  319. {
  320. CC_BREAK_IF(! text || ! info);
  321. id font = _createSystemFont(fontName, size);
  322. CC_BREAK_IF(! font);
  323. NSString * str = [NSString stringWithUTF8String:text];
  324. CC_BREAK_IF(!str);
  325. CGSize dimensions;
  326. dimensions.width = info->width;
  327. dimensions.height = info->height;
  328. NSTextAlignment nsAlign = FontUtils::_calculateTextAlignment(align);
  329. NSMutableParagraphStyle* paragraphStyle = FontUtils::_calculateParagraphStyle(enableWrap, overflow);
  330. paragraphStyle.alignment = nsAlign;
  331. // measure text size with specified font and determine the rectangle to draw text in
  332. UIColor *foregroundColor = [UIColor colorWithRed:info->tintColorR
  333. green:info->tintColorG
  334. blue:info->tintColorB
  335. alpha:info->tintColorA];
  336. // adjust text rect according to overflow
  337. NSMutableDictionary* tokenAttributesDict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
  338. foregroundColor,NSForegroundColorAttributeName,
  339. font, NSFontAttributeName,
  340. paragraphStyle, NSParagraphStyleAttributeName, nil];
  341. NSAttributedString *stringWithAttributes =[[[NSAttributedString alloc] initWithString:str
  342. attributes:tokenAttributesDict] autorelease];
  343. int shrinkFontSize = size;
  344. CGSize realDimensions;
  345. if (overflow == 2) {
  346. realDimensions = _calculateShrinkedSizeForString(&stringWithAttributes, font, dimensions, enableWrap, shrinkFontSize);
  347. } else {
  348. realDimensions = _calculateStringSize(stringWithAttributes, font, &dimensions, enableWrap, overflow);
  349. }
  350. CC_BREAK_IF(realDimensions.width <= 0 || realDimensions.height <= 0);
  351. if (dimensions.width <= 0) {
  352. dimensions.width = realDimensions.width;
  353. }
  354. if (dimensions.height <= 0) {
  355. dimensions.height = realDimensions.height;
  356. }
  357. // compute start point
  358. CGFloat yPadding = _calculateTextDrawStartHeight(align, realDimensions, dimensions);
  359. CGFloat xPadding = FontUtils::_calculateTextDrawStartWidth(align, realDimensions, dimensions);
  360. NSInteger POTWide = dimensions.width;
  361. NSInteger POTHigh = dimensions.height;
  362. CGRect textRect = CGRectMake(xPadding, yPadding,
  363. realDimensions.width, realDimensions.height);
  364. NSUInteger textureSize = POTWide * POTHigh * 4;
  365. unsigned char* data = (unsigned char*)malloc(sizeof(unsigned char) * textureSize);
  366. memset(data, 0, textureSize);
  367. // draw text
  368. CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
  369. CGContextRef context = CGBitmapContextCreate(data,
  370. POTWide,
  371. POTHigh,
  372. 8,
  373. POTWide * 4,
  374. colorSpace,
  375. kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
  376. if (!context)
  377. {
  378. CGColorSpaceRelease(colorSpace);
  379. CC_SAFE_FREE(data);
  380. break;
  381. }
  382. // text color
  383. CGContextSetRGBFillColor(context,
  384. info->tintColorR,
  385. info->tintColorG,
  386. info->tintColorB,
  387. info->tintColorA);
  388. // move Y rendering to the top of the image
  389. CGContextTranslateCTM(context, 0.0f, POTHigh);
  390. //NOTE: NSString draws in UIKit referential i.e. renders upside-down compared to CGBitmapContext referential
  391. CGContextScaleCTM(context, 1.0f, -1.0f);
  392. // store the current context
  393. UIGraphicsPushContext(context);
  394. CGColorSpaceRelease(colorSpace);
  395. CGContextSetShouldSubpixelQuantizeFonts(context, false);
  396. CGContextBeginTransparencyLayerWithRect(context, textRect, NULL);
  397. if ( info->hasStroke )
  398. {
  399. CGContextSetTextDrawingMode(context, kCGTextStroke);
  400. UIColor *strokeColor = [UIColor colorWithRed:info->strokeColorR
  401. green:info->strokeColorG
  402. blue:info->strokeColorB
  403. alpha:info->strokeColorA];
  404. NSMutableDictionary* tokenAttributesDict2 = [NSMutableDictionary dictionaryWithObjectsAndKeys:
  405. foregroundColor,NSForegroundColorAttributeName,
  406. font, NSFontAttributeName,
  407. paragraphStyle, NSParagraphStyleAttributeName, nil];
  408. [tokenAttributesDict2 setObject:[NSNumber numberWithFloat: info->strokeSize / shrinkFontSize * 100]
  409. forKey:NSStrokeWidthAttributeName];
  410. [tokenAttributesDict2 setObject:strokeColor forKey:NSStrokeColorAttributeName];
  411. NSAttributedString *strokeString =[[[NSAttributedString alloc] initWithString:str
  412. attributes:tokenAttributesDict2] autorelease];
  413. if(overflow == 2){
  414. _calculateShrinkedSizeForString(&strokeString, font, dimensions, enableWrap, shrinkFontSize);
  415. }
  416. [strokeString drawInRect:textRect];
  417. }
  418. CGContextSetTextDrawingMode(context, kCGTextFill);
  419. // actually draw the text in the context
  420. [stringWithAttributes drawInRect:textRect];
  421. CGContextEndTransparencyLayer(context);
  422. // pop the context
  423. UIGraphicsPopContext();
  424. // release the context
  425. CGContextRelease(context);
  426. // output params
  427. info->data = data;
  428. info->isPremultipliedAlpha = true;
  429. info->width = static_cast<int>(POTWide);
  430. info->height = static_cast<int>(POTHigh);
  431. bRet = true;
  432. } while (0);
  433. return bRet;
  434. }
  435. Data Device::getTextureDataForText(const char * text, const FontDefinition& textDefinition, TextAlign align, int &width, int &height, bool& hasPremultipliedAlpha)
  436. {
  437. Data ret;
  438. do {
  439. tImageInfo info = {0};
  440. info.width = textDefinition._dimensions.width;
  441. info.height = textDefinition._dimensions.height;
  442. info.hasShadow = textDefinition._shadow._shadowEnabled;
  443. info.shadowOffset.width = textDefinition._shadow._shadowOffset.width;
  444. info.shadowOffset.height = textDefinition._shadow._shadowOffset.height;
  445. info.shadowBlur = textDefinition._shadow._shadowBlur;
  446. info.shadowOpacity = textDefinition._shadow._shadowOpacity;
  447. info.hasStroke = textDefinition._stroke._strokeEnabled;
  448. info.strokeColorR = textDefinition._stroke._strokeColor.r / 255.0f;
  449. info.strokeColorG = textDefinition._stroke._strokeColor.g / 255.0f;
  450. info.strokeColorB = textDefinition._stroke._strokeColor.b / 255.0f;
  451. info.strokeColorA = textDefinition._stroke._strokeAlpha / 255.0f;
  452. info.strokeSize = textDefinition._stroke._strokeSize;
  453. info.tintColorR = textDefinition._fontFillColor.r / 255.0f;
  454. info.tintColorG = textDefinition._fontFillColor.g / 255.0f;
  455. info.tintColorB = textDefinition._fontFillColor.b / 255.0f;
  456. info.tintColorA = textDefinition._fontAlpha / 255.0f;
  457. if (! _initWithString(text, align, textDefinition._fontName.c_str(), textDefinition._fontSize, &info, textDefinition._enableWrap, textDefinition._overflow))
  458. {
  459. break;
  460. }
  461. height = info.height;
  462. width = info.width;
  463. ret.fastSet(info.data,width * height * 4);
  464. hasPremultipliedAlpha = true;
  465. } while (0);
  466. return ret;
  467. }
  468. void Device::setKeepScreenOn(bool value)
  469. {
  470. [[UIApplication sharedApplication] setIdleTimerDisabled:(BOOL)value];
  471. }
  472. /*!
  473. @brief Only works on iOS devices that support vibration (such as iPhone). Should only be used for important alerts. Use risks rejection in iTunes Store.
  474. @param duration ignored for iOS
  475. */
  476. void Device::vibrate(float duration)
  477. {
  478. // See http://stackoverflow.com/questions/4724980/making-the-iphone-vibrate
  479. // should vibrate no matter it is silient or not
  480. if([[UIDevice currentDevice].model isEqualToString:@"iPhone"])
  481. {
  482. AudioServicesPlaySystemSound (1352); //works ALWAYS as of this post
  483. }
  484. else
  485. {
  486. // Not an iPhone, so doesn't have vibrate
  487. // play the less annoying tick noise or one of your own
  488. AudioServicesPlayAlertSound (kSystemSoundID_Vibrate);
  489. }
  490. }
  491. NS_CC_END
  492. #endif // CC_PLATFORM_IOS