quick-cocos2dx之特效按钮——BubbleButton
来源:互联网 发布:如何进入it行业 知乎 编辑:程序博客网 时间:2024/05/21 08:56
local BubbleButton = {}-- create bubble buttonfunction BubbleButton.new(params) local listener = params.listener local button -- pre-reference params.listener = function(tag) if params.prepare then params.prepare() end local function zoom1(offset, time, onComplete) local x, y = button:getPosition() local size = button:getContentSize() size.width = 200 size.height = 200 local scaleX = button:getScaleX() * (size.width + offset) / size.width local scaleY = button:getScaleY() * (size.height - offset) / size.height transition.moveTo(button, {y = y - offset, time = time}) transition.scaleTo(button, { scaleX = scaleX, scaleY = scaleY, time = time, onComplete = onComplete, }) end local function zoom2(offset, time, onComplete) local x, y = button:getPosition() local size = button:getContentSize() size.width = 200 size.height = 200 transition.moveTo(button, {y = y + offset, time = time / 2}) transition.scaleTo(button, { scaleX = 1.0, scaleY = 1.0, time = time, onComplete = onComplete, }) end --按钮执行效果期间设置为不可点击 button:setButtonEnabled(false) zoom1(40, 0.08, function() zoom2(40, 0.09, function() zoom1(20, 0.10, function() zoom2(20, 0.11, function() --按钮执行效果完成后设置为可以点击 button:setButtonEnabled(true) listener(tag) end) end) end) end) end button = cc.ui.UIPushButton.new({normal = params.image}) button:onButtonClicked(function(tag) params.listener(tag) end) return buttonendreturn BubbleButton
使用方法:
self.startButton = BubbleButton.new({ image = "#MenuSceneStartButton.png", sound = GAME_SFX.tapButton, prepare = function() audio.playSound(GAME_SFX.tapButton) self.startButton:setButtonEnabled(false) end, listener = function() --do something end, }) :align(display.CENTER, display.right - 150, display.bottom + 300) :addTo(self)
0 0
- quick-cocos2dx之特效按钮——BubbleButton
- quick-cocos2dx之特效按钮——缩放按钮
- quick cocos2dx grid3d 特效整理
- cocos2dx之场景特效
- quick-cocos2dx绑定cocostuido按钮的问题
- javascript网页特效——按钮特效
- 我的Qt学习之路——按钮特效
- Quick Cosos2Dx技术(三)——LDT+quick-x-player调试quick cocos2dx项目
- quick cocos2dx 实例——lua基础01
- 【COCOS2DX-游戏开发之二四】 quick-cocos2dx
- quick-cocos2dx cocos2dx.lua
- cocos2dx-3.2之按钮变化
- 【H5+ & Quick-cocos2dx整合】之iOS 三 集成Quick-Cocos2dx SDK
- 【H5+ & Quick-cocos2dx整合】之iOS 四 协调H5+和Quick-Cocos2dx之间工作
- 游戏特效之Cocos2dx中的粒子系统
- cocos2dx自学之 动作特效与场景切换特效
- cocos2dx 特效
- cocos2dx特效
- PLSQL(1基本简单语句块)
- 从头认识java-5.3 public private protected
- ORACLE数据库笔记
- 151029总结
- GSON的用法
- quick-cocos2dx之特效按钮——BubbleButton
- Masonry介绍与使用实践:快速上手Autolayout
- Vi编辑器
- 判断字符串为空的方法
- Cgroup框架分析
- 复选框(checkbox)和单选框(radio)与文字居中对齐
- 如何面对客户的紧急需求
- 学习windows驱动(框架和IO请求)
- Cordys HTML5 多语言代码 解读