html5转-JSBingDing-IOS基本用法使用心得(持续更新中)

  • 本帖最后由 黄泊泊 于 2012-12-14 17:09 编辑 *

2012-12-01当前版本的基本功能使用总结,多有不足,敬请补充,见谅!!!1数组的末尾 ,sesquence里面末尾 能够不用null就不用吧。2 var animation =cc.Animation.create(null,0.2); 类似于这种播放动画的 代码,不这样写了。写成如下格式:var animation =cc.Animation.create(); animation.setDelayPerUnit(0.2);3跳转代码:能够这样写就这样写最好:var scene =cc.Scene.create();scene.addChild(FavorMenu.create());cc.Director.getInstance().replaceScene(cc.TransitionFade.create(1.2,scene));
那么对应的 场景里面的 函数就要写成FavorMenu.create = function () {
var sg = new FavorMenu();
if (sg && sg.init()) {
return sg;
}
return null;
};

FavorMenu.scene = function () {
var scene = cc.Scene.create();
var layer = FavorMenu.create();
scene.addChild(layer);
return scene;
};好像是 cocos2d老版本的写法,新版本跳转和场景对应上了应该也过的去
4 ag只能用整形数5cc.CallFunc.create(this.onCallback1, this),方法在前 this在后。 6 如果可以的话,请把cc.Rect.CCRectContainsPoint写成cc.rectContainsPoint7能够不用touch就不用,多用imageItem8
cc.PointZero
写成
cc.p(0,0)9类似于ball11.getBoundingBox().size.height直接写成ball11.getContentSize().height10cc. cc.PointMake 写成cc.p11菜单的写法举例 var item1 = cc.MenuItemImage.create(s_pathB1,s_pathB2, this.onBackCallback, this); var item2 = cc.MenuItemImage.create(s_pathR1,s_pathR2, this.onRestartCallback, this); var item3 = cc.MenuItemImage.create(s_pathF1,s_pathF2, this.onNextCallback, this);
var menu = cc.Menu.create(item1, item2, item3);
menu.setPosition(0,0); item1.setPosition(s.width / 2 -item2.getContentSize().width * 2, item2.getContentSize().height / 2); item2.setPosition(s.width / 2, item2.getContentSize().height/ 2); item3.setPosition(s.width / 2 +item2.getContentSize().width * 2, item2.getContentSize().height / 2);
this.addChild(menu, 1); 。。。。。。onBackCallback:function (sender) {}, onRestartCallback:function(sender) {}, onNextCallback:function (sender){}12jsb v2.0 按帧播放动画 var animation = cc.Animation.create();
for (var i = 1; i < 15; i++) {
varframeName = “res/Images/grossini_dance_” + ((i < 10) ?(“0” + i) : i) + “.png”;
animation.addSpriteFrameWithFile(frameName);
}
animation.setDelayPerUnit(2.8 / 14);
animation.setRestoreOriginalFrame(true);

    var action =cc.Animate.create(animation);
   this._grossini.runAction(cc.Sequence.create(action, action.reverse()));13

![](file://localhost/Users/xhuangxiaoqiang/Library/Caches/TemporaryItems/msoclip/0clip_image002.gif)
jsb V2.0plist播放动画 caoAction:function(){
var cache =cc.SpriteFrameCache.getInstance();
cache.addSpriteFrames(plist_MainMenu_cao,img_MainMenu_cao);
var cao =cc.Sprite.createWithSpriteFrame(cache.getSpriteFrame(“Hy_cao_1.png”));
cao.setPosition(cc.p(776,768-703.5));
this.addChild(cao,5);
var animFrame = ];
for(var a = 1; a < 5; a++){
var str =“Hy_cao_”+ a +".png";
animFrame.push(cache.getSpriteFrame(str));
}
var animation =cc.Animation.create(animFrame,0.8);
cao.runAction(cc.RepeatForever.create(cc.Sequence.create(
cc.Animate.create(animation),cc.DelayTime.create(3)
)));
},
14、背景音乐播放:cc.AudioEngine.getInstance().setMusicVolume(0.99); cc.AudioEngine.getInstance().playMusic(s_mainMainMusic, true); 暂停:cc.AudioEngine.getInstance().pauseMusic();恢复:cc.AudioEngine.getInstance().resumeMusic();音效播放var s =cc.AudioEngine.getInstance().playEffect(s_buttonEffect);停止:cc.AudioEngine.getInstance().stopEffect(s_buttonEffect);15、显示和隐藏 sender.setVisible(false);使能与否backbar.setEnabled(false);16.setScale 分开写 setScaleX和setScaleY

感谢楼主填坑:lol

作?用LUA的人,?於JSB可以用正?的?承表示很羡慕。
或?自己要做的?人?目?考?用JSB吧,不?不知道JSB的性能是否和LUA接近。

因?公司的上??目用的是倒楣的NGCore,一??乎完全用JS的框架,屏幕上有上百?精?就?始?慢,於是?JS的性能?生了些?疑。
不?似乎只要不?Spider-Monkey的JS???,只是作???接口,可能?是有接近于LUA的性能。

{:soso_e179:} 这个很好,很有用

{:soso_e113:}楼主经验之谈。

{:soso_e142:}先顶再看

感谢楼主的经验总结,下个版本发布的时候,我们一定好好检查,尽量将已知的bug修复。

感谢楼主填坑:lol

{:soso_e179:} 这个很好,很有用

{:soso_e142:}先顶再看

感谢楼主的经验总结,下个版本发布的时候,我们一定好好检查,尽量将已知的bug修复。