博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
cocos-lua
阅读量:6885 次
发布时间:2019-06-27

本文共 1696 字,大约阅读时间需要 5 分钟。

function YZMGame33:initAnimate(path,row, col, width, height, delay)

  local perWidth = width/col;
  local perHeight = height/row;
  local animation = cc.Animation:create();
  for i=1,row do
    for j=1,col do
      local spFrame = cc.SpriteFrame:create(path,cc.rect((j-1)*perWidth,(i-1)*perHeight,perWidth,perHeight));
      animation:addSpriteFrame(spFrame);
    end
    end
  animation:setDelayPerUnit(delay or 0.2);
  animation:setLoops(-1);
  local animate = cc.Animate:create(animation);
  return animate;
end

 

function YZMGame33:initMenu()

  local menu = cc.Menu:create()  
  menu:setPosition(cc.p(0, self.bg_bottom:getPositionY()-80))
  self:addChild(menu);

  self.btn_start = self:initButton("yzm/yzm_button_bt_start.png",179,210);

  self.btn_start:addTo(menu);
  self.btn_start:setPosition(cc.p(1030, 48));

  self.btn_stop = self:initButton("yzm/yzm_button_bt_stop.png",179,210);

  self.btn_stop:setPosition(cc.p(1030, 48));
  self.btn_stop:setVisible(false);
  self.btn_stop:addTo(menu);

  self.btn_auto = self:initButton("yzm/yzm_button_bt_auto.png",131,192);

  self.btn_auto:setPosition(cc.p(875,48));
  self.btn_auto:addTo(menu);
end

function YZMGame33:initButton(path, width, height)
  local stateNum = 3;
  local menuItemImage = cc.MenuItemImage:create();
  for i=1,stateNum do
    local btn_state = cc.SpriteFrame:create(path, cc.rect(0,(i-1)*height/3,width,height/3));
    if i == 1 then
      menuItemImage:setNormalSpriteFrame(btn_state);
    elseif i == 2 then
      menuItemImage:setSelectedSpriteFrame(btn_state);
    else
      menuItemImage:setDisabledSpriteFrame(btn_state);
    end
  end
  return menuItemImage;
end

转载于:https://www.cnblogs.com/sujiehaojava/p/7667713.html

你可能感兴趣的文章
283-移动零
查看>>
nodejs+express+mongodb写api接口的简单尝试
查看>>
grub密码
查看>>
说好的不熬夜呢???!!!! -- 超市项目
查看>>
Apache遇到的问题:APR not found
查看>>
运行webpack-dev-srerver 端口占用错误及解决办法
查看>>
html-php深入理解
查看>>
第 11 章 日志管理 - 088 - Docker 如何支持多种日志方案?
查看>>
课后作业-----输入法评价
查看>>
使用qemu
查看>>
静态页之间传值
查看>>
01.Hibernate快速入门
查看>>
ThinkPHP3.2判断是否为手机端访问并跳转到另一个模块的方法
查看>>
人事管理系统——11个基础信息管理界面
查看>>
关于联想超极本出现蓝屏Default Boot Device Missing or Boot Failed的解决办法
查看>>
solr索引报错(java.lang.OutOfMemoryError:GC overhead limit exceeded)
查看>>
python基础2--小结篇
查看>>
Ajax传统操作
查看>>
webpack01
查看>>
NoSQL 简介
查看>>