Cocos2d-js02_实现UI流程和场景跳转
/** * Created by chaoge on 15/6/19. */ @H_403_7@var @H_403_7@MenuLayer @H_403_7@= cc@H_403_7@.Layer@H_403_7@.extend@H_403_7@({ sprite@H_403_7@:null@H_403_7@,helloLabel@H_403_7@:null@H_403_7@,size@H_403_7@:null@H_403_7@,ctor@H_403_7@:function @H_403_7@() { this@H_403_7@._super@H_403_7@(); size @H_403_7@= cc@H_403_7@.winSize; //@H_403_7@开始按钮@H_403_7@ @H_403_7@var @H_403_7@start @H_403_7@= new @H_403_7@cc@H_403_7@.MenuItemImage@H_403_7@( res@H_403_7@.start@H_403_7@,res@H_403_7@.start@H_403_7@,function @H_403_7@() { cc@H_403_7@.log@H_403_7@("Menu is clicked!"@H_403_7@); cc@H_403_7@.director.runScene@H_403_7@(new @H_403_7@GameScene@H_403_7@()); },this@H_403_7@); start@H_403_7@.attr@H_403_7@({ x@H_403_7@: size@H_403_7@.width@H_403_7@/2@H_403_7@,y@H_403_7@: size@H_403_7@.height@H_403_7@/2@H_403_7@-120@H_403_7@,anchorX@H_403_7@: 0.5@H_403_7@,anchorY@H_403_7@: 0.5 @H_403_7@}); //@H_403_7@关于按钮@H_403_7@ @H_403_7@var @H_403_7@about @H_403_7@= new @H_403_7@cc@H_403_7@.MenuItemImage@H_403_7@( res@H_403_7@.about@H_403_7@,res@H_403_7@.about@H_403_7@,function @H_403_7@() { cc@H_403_7@.log@H_403_7@("Menu is clicked!"@H_403_7@); cc@H_403_7@.director.runScene@H_403_7@(new @H_403_7@AboutGame@H_403_7@()); },this@H_403_7@); about@H_403_7@.attr@H_403_7@({ x@H_403_7@: size@H_403_7@.width@H_403_7@/2@H_403_7@,y@H_403_7@: size@H_403_7@.height@H_403_7@/2@H_403_7@-280@H_403_7@,anchorY@H_403_7@: 0.5 @H_403_7@}); var @H_403_7@menu @H_403_7@= new @H_403_7@cc@H_403_7@.Menu@H_403_7@(start@H_403_7@,about@H_403_7@); menu@H_403_7@.x @H_403_7@= 0@H_403_7@; menu@H_403_7@.y @H_403_7@= 0@H_403_7@; this@H_403_7@.addChild@H_403_7@(menu@H_403_7@,1@H_403_7@); //@H_403_7@滚动菜单@H_403_7@ @H_403_7@helloLabel @H_403_7@= new @H_403_7@cc@H_403_7@.LabelTTF@H_403_7@("@H_403_7@看谁最长@H_403_7@"@H_403_7@,"Arial"@H_403_7@,38@H_403_7@); // position the label on the center of the screen @H_403_7@helloLabel@H_403_7@.x @H_403_7@= size@H_403_7@.width @H_403_7@/ 2@H_403_7@; helloLabel@H_403_7@.y @H_403_7@= size@H_403_7@.height@H_403_7@-100@H_403_7@; // add the label as a child to this layer @H_403_7@this@H_403_7@.addChild@H_403_7@(helloLabel@H_403_7@,5@H_403_7@); // add "HelloWorld" splash screen" @H_403_7@this@H_403_7@.sprite @H_403_7@= new @H_403_7@cc@H_403_7@.Sprite@H_403_7@(res@H_403_7@.zhuye@H_403_7@); this@H_403_7@.sprite@H_403_7@.attr@H_403_7@({ x@H_403_7@: size@H_403_7@.width @H_403_7@/ 2@H_403_7@,y@H_403_7@: size@H_403_7@.height @H_403_7@/ 2 @H_403_7@}); this@H_403_7@.addChild@H_403_7@(this@H_403_7@.sprite@H_403_7@,0@H_403_7@); this@H_403_7@.schedule@H_403_7@(this@H_403_7@.LabelMove@H_403_7@,0.2@H_403_7@); },LabelMove @H_403_7@: function@H_403_7@(){ helloLabel@H_403_7@.setPositionX@H_403_7@(helloLabel@H_403_7@.getPositionX@H_403_7@()-10@H_403_7@); if@H_403_7@(helloLabel@H_403_7@.getPositionX@H_403_7@() <= -50@H_403_7@){ helloLabel@H_403_7@.setPositionX@H_403_7@(size@H_403_7@.width@H_403_7@); } } }); var @H_403_7@MenuGame @H_403_7@= cc@H_403_7@.Scene@H_403_7@.extend@H_403_7@({ onEnter@H_403_7@:function @H_403_7@() { this@H_403_7@._super@H_403_7@(); var @H_403_7@layer @H_403_7@= new @H_403_7@MenuLayer@H_403_7@(); this@H_403_7@.addChild@H_403_7@(layer@H_403_7@); } });
}
2、关于界面的代码,实现网页链接AboutScene.js:
var @H_403_7@labjiumiao @H_403_7@= new @H_403_7@cc@H_403_7@.LabelTTF@H_403_7@("9@H_403_7@秒课堂@H_403_7@"@H_403_7@, 38@H_403_7@);
var @H_403_7@ketang @H_403_7@= new @H_403_7@cc@H_403_7@.MenuItemLabel@H_403_7@(labjiumiao@H_403_7@,function@H_403_7@(){
window@H_403_7@.location@H_403_7@.href @H_403_7@= "http://www.9miaoketang.com"@H_403_7@;
});
ketang@H_403_7@.setPosition@H_403_7@(cc@H_403_7@.p@H_403_7@(size@H_403_7@.width@H_403_7@/2@H_403_7@,size@H_403_7@.height@H_403_7@-200@H_403_7@));
var @H_403_7@h5kaifa @H_403_7@= new @H_403_7@cc@H_403_7@.LabelTTF@H_403_7@("COCOS2D-HTML5 @H_403_7@游戏开发@H_403_7@"@H_403_7@, 38@H_403_7@);
var @H_403_7@H5 @H_403_7@= new @H_403_7@cc@H_403_7@.MenuItemLabel@H_403_7@(h5kaifa@H_403_7@,function@H_403_7@(){
window@H_403_7@.location@H_403_7@.href @H_403_7@= "http://h5.9miao.com"@H_403_7@;
});
H5@H_403_7@.setPosition@H_403_7@(cc@H_403_7@.p@H_403_7@(size@H_403_7@.width@H_403_7@/2@H_403_7@,size@H_403_7@.height@H_403_7@/2@H_403_7@));
var @H_403_7@menu @H_403_7@= new @H_403_7@cc@H_403_7@.Menu@H_403_7@(ketang@H_403_7@,H5@H_403_7@);
menu@H_403_7@.x @H_403_7@ = 0@H_403_7@;
menu@H_403_7@.y @H_403_7@ = 0@H_403_7@;
this@H_403_7@.addChild@H_403_7@(menu@H_403_7@,1@H_403_7@);
视频地址:http://www.9miaoketang.com/course/37
课程讨论帖地址:http://www.9miao.com/thread-64587-1-1.html
源码地址:https://store.cocos.com/stuff/show/128289.html
QQ交流群:83459374
后期也会把该源码传在群里面去,欢迎大家加入讨论!