如下为cocos2dx lua实现的按钮放大缩小功能,使用起来非常简单:
local function buttonEvent(sender,eventType)if eventType == ccui.TouchEventType.began then local scale = cc.ScaleTo:create(1,0.8) local ease_elastic = cc.EaseElasticOut:create(scale) sender:runAction(ease_elastic) elseif eventType == ccui.TouchEventType.ended then local scale = cc.ScaleTo:create(1,1) local ease_elastic = cc.EaseElasticOut:create(scale) sender:runAction(ease_elastic) elseif eventType == ccui.TouchEventType.canceled then local scale = cc.ScaleTo:create(1,1) local ease_elastic = cc.EaseElasticOut:create(scale) sender:runAction(ease_elastic)endend