mirror of https://github.com/axmolengine/axmol.git
add call reflection with bool test case
This commit is contained in:
parent
d6c039f528
commit
2ef2016c39
|
@ -29,5 +29,6 @@
|
||||||
+(void) callNativeWithParam:(NSString *)str;
|
+(void) callNativeWithParam:(NSString *)str;
|
||||||
+(NSString *)callNativeWithReturnString;
|
+(NSString *)callNativeWithReturnString;
|
||||||
+(BOOL)callNativeUIWithTitle:(NSString *) title andContent:(NSString *)content;
|
+(BOOL)callNativeUIWithTitle:(NSString *) title andContent:(NSString *)content;
|
||||||
|
+(BOOL)callNativeUIWithTitle:(NSString *) title andContent:(NSString *)content addBool:(BOOL)logicSwitch;
|
||||||
+(int)callNativeWithAdd:(NSNumber *)num1 and:(NSNumber *)num2;
|
+(int)callNativeWithAdd:(NSNumber *)num1 and:(NSNumber *)num2;
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -50,6 +50,19 @@
|
||||||
[alertView show];
|
[alertView show];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
+(BOOL)callNativeUIWithTitle:(NSString *) title andContent:(NSString *)content addBool:(BOOL)logicSwitch{
|
||||||
|
if (logicSwitch)
|
||||||
|
{
|
||||||
|
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title message:content delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"it's true", nil];
|
||||||
|
[alertView show];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title message:content delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"it's false", nil];
|
||||||
|
[alertView show];
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
#elif TARGET_OS_MAC
|
#elif TARGET_OS_MAC
|
||||||
|
|
||||||
+(BOOL)callNativeUIWithTitle:(NSString *) title andContent:(NSString *)content{
|
+(BOOL)callNativeUIWithTitle:(NSString *) title andContent:(NSString *)content{
|
||||||
|
@ -63,5 +76,24 @@
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+(BOOL)callNativeUIWithTitle:(NSString *) title andContent:(NSString *)content addBool:(BOOL)logicSwitch{
|
||||||
|
NSAlert *alert = [[NSAlert alloc] init];
|
||||||
|
if (logicSwitch)
|
||||||
|
{
|
||||||
|
[alert addButtonWithTitle:@"it's true"];
|
||||||
|
[alert addButtonWithTitle:@"Cancel"];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[alert addButtonWithTitle:@"it's false"];
|
||||||
|
[alert addButtonWithTitle:@"Cancel"];
|
||||||
|
}
|
||||||
|
|
||||||
|
[alert setMessageText:title];
|
||||||
|
[alert setInformativeText:content];
|
||||||
|
[alert setAlertStyle:NSWarningAlertStyle];
|
||||||
|
[alert runModal];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -41,12 +41,19 @@ var ReflectionTestLayer = BaseTestLayer.extend({
|
||||||
cc.log("ret val is "+ret);
|
cc.log("ret val is "+ret);
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
menuItem.x = winSize.width / 2;
|
|
||||||
menuItem.y = winSize.height / 2;
|
|
||||||
|
|
||||||
var menu = new cc.Menu(menuItem);
|
var label2 = new cc.LabelTTF("CallReflectionWithBool", "Arial", 35);
|
||||||
menu.x = 0;
|
var menuItem2 = new cc.MenuItemLabel(label2, function(){
|
||||||
menu.y = 0;
|
if(cc.sys.os == cc.sys.OS_ANDROID){
|
||||||
|
jsb.reflection.callStaticMethod("org/cocos2dx/js_tests/AppActivity", "showAlertDialog", "(Ljava/lang/String;Ljava/lang/String;)V", "How are you ?", "I'm great !");
|
||||||
|
}else if(cc.sys.os == cc.sys.OS_IOS || cc.sys.os == cc.sys.OS_OSX){
|
||||||
|
var ret = jsb.reflection.callStaticMethod("NativeOcClass","callNativeUIWithTitle:andContent:addBool:","cocos2d-js","Yes! you call a Native UI from Reflection", true);
|
||||||
|
cc.log("ret val is "+ret);
|
||||||
|
}
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
var menu = new cc.Menu(menuItem, menuItem2);
|
||||||
|
menu.alignItemsVerticallyWithPadding(4);
|
||||||
|
|
||||||
this.addChild(menu);
|
this.addChild(menu);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue