Cocos2d-x   发布时间:2022-05-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Cocos2d-js02_实现UI流程和场景跳转大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

Cocos2d-js02_实现UI流程和场景跳转

1、菜单场景代码:

/** * Created by chaoge on 15/6/19. */ var @H_867_13@menuLayer = cc.Layer.extend({
 sprite:null,HelloLabel:null,size:null,ctor:function () {
 this._super();

 size = cc.winSize;

 //开始按钮  var start = new cc.@H_867_13@menuItemImage(
 res.start,res.start,function () {
 cc.log("Menu is clicked!");
 cc.director.runScene(new GameScene());

 },this);
 start.attr({
 x: size.width/2,y: size.height/2-120,anchorX: 0.5,anchorY: 0.5
 });

 //关于按钮  var about = new cc.@H_867_13@menuItemImage(
 res.about,res.about,function () {
 cc.log("Menu is clicked!");
 cc.director.runScene(new AboutGame());

 },this);
 about.attr({
 x: size.width/2,y: size.height/2-280,anchorY: 0.5
 });

 var @H_578_91@menu = new cc.@H_867_13@menu(start,about);
 @H_578_91@menu.x = 0;
 @H_578_91@menu.y = 0;
 this.addChild(@H_578_91@menu,1);


 //滚动菜单  HelloLabel = new cc.LabelTTF("看谁最长","Arial",38);
 // position the label on the center of the screen  HelloLabel.x = size.width / 2;
 HelloLabel.y = size.height-100;
 // add the label as a child to this layer  this.addChild(HelloLabel,5);

 // add "HelloWorld" splash screen"  this.sprite = new cc.Sprite(res.zhuye);
 this.sprite.attr({
 x: size.width / 2,y: size.height / 2
 });
 this.addChild(this.sprite,0);

 this.schedule(this.LabelMove,0.2);
 },LabelMove : function(){
 HelloLabel.setPositionX(HelloLabel.getPositionX()-10);
 if(HelloLabel.getPositionX() <= -50){
 HelloLabel.setPositionX(size.width);
 }

 }
});
var @H_867_13@menuGame = cc.Scene.extend({
 onEnter:function () {
 this._super();
 var layer = new @H_867_13@menuLayer();
 this.addChild(layer);
 }
});
 

}

2、关于界面的代码,实现网页链接AboutScene.js:

var labjiumiao = new cc.LabelTTF("9秒课堂", 38);@H_197_713@ var ketang = new cc.@H_867_13@menuItemLabel(labjiumiao,function(){@H_197_713@ window.LOCATIOn.href = "http://www.9miaoketang.com";@H_197_713@ });@H_197_713@ ketang.setPosition(cc.p(size.width/2,size.height-200));@H_197_713@ @H_197_713@ var h5Kaifa = new cc.LabelTTF("COCOS2D-HTML5 游戏开发", 38);@H_197_713@ var H5 = new cc.@H_867_13@menuItemLabel(h5Kaifa,function(){@H_197_713@ window.LOCATIOn.href = "http://h5.9miao.com";@H_197_713@ });@H_197_713@ H5.setPosition(cc.p(size.width/2,size.height/2));@H_197_713@ @H_197_713@ @H_197_713@ var @H_578_91@menu = new cc.@H_867_13@menu(ketang,H5);@H_197_713@ @H_578_91@menu.x = 0;@H_197_713@ @H_578_91@menu.y = 0;@H_197_713@ this.addChild(@H_578_91@menu,1);

@H_197_713@

@H_197_713@

视频地址: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

后期也会把该源码传在群里面去,欢迎大家加入讨论!

大佬总结

以上是大佬教程为你收集整理的Cocos2d-js02_实现UI流程和场景跳转全部内容,希望文章能够帮你解决Cocos2d-js02_实现UI流程和场景跳转所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。