zoukankan      html  css  js  c++  java
  • cocos-lua

    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

  • 相关阅读:
    小程序之滚动选择器(时间、普通、日期)
    bzoj 4825: [Hnoi2017]单旋 LCT
    bzoj 4821: [Sdoi2017]相关分析 线段树
    bzoj 4766: 文艺计算姬 矩阵树定理
    bzoj 4031: 小Z的房间 矩阵树定理
    bzoj 4822~4824 CQOI2017题解
    bzoj 4817: [Sdoi2017]树点涂色 LCT+树链剖分+线段树
    bzoj 4816: [Sdoi2017]数字表格
    bzoj 4537: [Hnoi2016]最小公倍数 分块+并查集
    bzoj 4653: [Noi2016]区间
  • 原文地址:https://www.cnblogs.com/sujiehaojava/p/7667713.html
Copyright © 2011-2022 走看看