mirror of https://github.com/axmolengine/axmol.git
Merge pull request #4997 from dumganhar/iss3619
Merge PR #4085: Fix of ControlButton doesn't support to set scale ratio of touchdown state
This commit is contained in:
commit
811271e5a1
|
@ -80,13 +80,13 @@ bool ControlButton::initWithLabelAndBackgroundSprite(Node* node, Scale9Sprite* b
|
|||
_parentInited = true;
|
||||
|
||||
_isPushed = false;
|
||||
_zoomOnTouchDown = true;
|
||||
|
||||
// Adjust the background image by default
|
||||
setAdjustBackgroundImage(true);
|
||||
setPreferredSize(Size::ZERO);
|
||||
// Zooming button by default
|
||||
_zoomOnTouchDown = true;
|
||||
_scaleRatio = 1.1f;
|
||||
|
||||
// Set the default anchor point
|
||||
ignoreAnchorPointForPosition(false);
|
||||
|
@ -199,7 +199,7 @@ void ControlButton::setHighlighted(bool enabled)
|
|||
needsLayout();
|
||||
if( _zoomOnTouchDown )
|
||||
{
|
||||
float scaleValue = (isHighlighted() && isEnabled() && !isSelected()) ? 1.1f : 1.0f;
|
||||
float scaleValue = (isHighlighted() && isEnabled() && !isSelected()) ? _scaleRatio : 1.0f;
|
||||
Action *zoomAction = ScaleTo::create(0.05f, scaleValue);
|
||||
zoomAction->setTag(kZoomActionTag);
|
||||
runAction(zoomAction);
|
||||
|
|
|
@ -226,6 +226,8 @@ protected:
|
|||
|
||||
/** Adjust the button zooming on touchdown. Default value is YES. */
|
||||
CC_PROPERTY(bool, _zoomOnTouchDown, ZoomOnTouchDown);
|
||||
/** Scale ratio button on touchdown. Default value 1.1f */
|
||||
CC_SYNTHESIZE(float, _scaleRatio, ScaleRatio);
|
||||
|
||||
CC_PROPERTY_PASS_BY_REF(Point, _labelAnchorPoint, LabelAnchorPoint);
|
||||
|
||||
|
|
Loading…
Reference in New Issue