1
2
3
4
5
6
7
8
9
10
11
12
|
// add a "close" icon to exit the progress. it's an autorelease object
var
closeItem = cc.MenuItemImage.create(
"res/CloseNormal.png"
,
"res/CloseSelected.png"
cc.log(
"close button was clicked."
);
},
this
);
closeItem.setAnchorPoint(cc.p(0.5,0.5));
menu = cc.Menu.create(closeItem);
menu.setPosition(cc.p(0,0));
.addChild(menu,1);
closeItem.setPosition(cc.p(size.width - 20,20));
|
// "create" in JS
// cc.MenuItemImage.create( normalImage,selectedImage,[disabledImage],callback_fn,[this]
JSBool js_cocos2dx_CCMenuItemImage_create(JSContext *cx,uint32_t argc,jsval *vp)
{
if
(argc >= 2 && argc <= 5) {
jsval *argv = JS_ARGV(cx,vp);
JSStringWrapper arg0(argv[0]);
JSStringWrapper arg1(argv[1]);
JSStringWrapper arg2;
jsval jsCallback = JSVAL_VOID;
jsval jsThis = JSVAL_VOID;
int
last = 2;
(argc >= 3) {
thirdArgIsString = argv[2].isString();
(thirdArgIsString) {
arg2.set(argv[2],cx);
last = 3;
}
}
cocos2d::MenuItemImage* ret = cocos2d::MenuItemImage::create(arg0.get(),arg1.get(),std::string(arg2.get()));
(argc >= 3) {
(!thirdArgIsString) {
//cc.MenuItemImage.create( normalImage,[this] )
jsCallback = argv[last++];
(argc == 4) {
jsThis = argv[last];
}
}
else
{
(argc >= 4) {
jsCallback = argv[last++];
(argc == 5) {
jsThis = argv[last];
}
}
}
}
JSObject *obj = bind_menu_item<cocos2d::MenuItemImage>(cx,ret,jsCallback,jsThis);
JS_SET_RVAL(cx,vp,OBJECT_TO_JSVAL(obj));
return
JS_TRUE;
}
JS_ReportError(cx,
"Invalid number of arguments. Expecting: 2 <= args <= 5"
);
JS_FALSE;
}
(argc >= 3) {
(!thirdArgIsString) {
jsCallback = argv[last++];
(argc == 4) {
jsThis = argv[last];
}
}
{
(argc >= 4) {
jsCallback = argv[last++];
(argc == 5) {
jsThis = argv[last];
}
}
}
}