• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
Developer_方方
博客园    首页    新随笔    联系   管理    订阅  订阅

Cocos2d JS 之消灭星星(六) 创建星星类

 1 /*
 2  * 创建星星类(所有的星星都在这里创建,星星拥有的所有性都在这里实现)
 3  */
 4 var GameCreateStar = ccui.ImageView.extend(
 5 {
 6     type:0,//星星的类型(不同数字代表不同颜色的星星);
 7     normalType:null,//星星的类型(不同数字代表不同颜色的星星);主要作用是当两次选择的星星列表不一样时,还原初始type值
 8     isSelected:false,//是否选中
 9     col:null,//水平方向排列位置(0-9)
10     row:null,//竖直方向排列位置(0-9)
11     normal:null,//通常状态图片纹理
12     selected:null,//选中状态图片纹理
13     count:0,//纪录当前选中次数,主要作用是当选择好要消除的星星后,实现再点一次则消灭星星
14     ctor:function(normal, type, selected, col, row)
15     {
16         this.type = type;
17         this.normalType = type;
18         this._super();
19         this.col = col;
20         this.row = row;
21         this.normal = normal;
22         this.selected = selected;
23         this.loadTexture(normal);
24         this.setAnchorPoint(0, 0);
25     },
26     //当点击星星的时候,加载不同状态的图片纹理
27     updateTexture:function()
28     {
29         if(this.isSelected)
30         {
31             this.loadTexture(this.selected);
32         }
33         else
34         {
35             this.loadTexture(this.normal);
36         }
37     }
38 });

 

posted @ 2014-10-30 20:20  Developer_方方  阅读(591)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3