cocos2d-X 节点(LayoutParameter.h)API

本文介绍了cocos2d-X中关于LayoutParameter.h的API,探讨了节点的布局参数,包括相对布局和线性布局的重要概念。
摘要由CSDN通过智能技术生成

本文来自http://blog.csdn.net/runaying ,引用必须注明出处!

cocos2d-X 节点(LayoutParameter.h)API

温馨提醒:为了大家能更好学习,强烈推荐大家看看本人的这篇博客 Cocos2d-X权威指南笔记

一些布局参数,相对布局参数,线性布局参数

///cocos2d-x-3.0alpha0/extensions/CocoStudio/GUI/Layouts
// 一些布局参数,相对布局参数,线性布局参数


#ifndef __LAYOUTPARMETER_H__
#define __LAYOUTPARMETER_H__

#include "UILayoutDefine.h"

NS_CC_EXT_BEGIN

typedef enum
{
    LAYOUT_PARAMETER_NONE,
    LAYOUT_PARAMETER_LINEAR,
    LAYOUT_PARAMETER_RELATIVE
}LayoutParameterType;

class LayoutParameter : public Object
{
public:
    /**
     * Default constructor
     */
    LayoutParameter() : _margin(UIMargin()){_layoutParameterType = LAYOUT_PARAMETER_NONE;};
    
    /**
     * Default destructor
     */
    virtual ~LayoutParameter(){};
    
    /**
     * Allocates and initializes.
     * @return 一个初始化的被标记为自动释放的 LayoutParameter
     */
    static LayoutParameter* create();
    
    /**
     * 为 LayoutParameter 设置 margin (边距)参数.
     *
     * @see UIMargin
     *
     * @param margin
     */
    void setMargin(const UIMargin& margin);
    const UIMargin& getMargin() const;
    
    /**
     * Gets LayoutParameterType of LayoutParameter.
     *
     * @see LayoutParameterType
     *
     * @return LayoutParameterType
     */
    LayoutParameterType getLayoutType() const;
protected:
    UIMargin _margin;
    LayoutParameterType _layoutParameterType;
};

class LinearLayoutParameter : public LayoutParameter
{
public:
    /**
     * Default constructor
     */
    LinearLayoutParameter() : m_eLinearGravity(LINEAR_GRAVITY_NONE){_layoutParameterType = LAYOUT_PARAMETER_LINEAR;};
    
    /**
     * Default destructor
     */
    virtual ~LinearLayoutParameter(){};
    
    /**
     * 分配并初始化.
     * @return A initialized LayoutParameter which is marked as "autorelease".
     */
    static LinearLayoutParameter* create();
    
    /**
     * Sets UILinearGravity parameter for LayoutParameter.
     *
     * @see UILinearGravity
     *
     * @param UILinearGravity
     */
    void setGravity(UILinearGravity gravity);
    UILinearGravity getGravity() const;
protected:
    UILinearGravity m_eLinearGravity;
};

class RelativeLayoutParameter : public LayoutParameter
{
public:
    /**
     * Default constructor
     */
    RelativeLayoutParameter() : m_eRelativeAlign(RELATIVE_ALIGN_NONE),m_strRelativeWidgetName(""),m_strRelativeLayoutName(""){_layoutParameterType = LAYOUT_PARAMETER_RELATIVE;};
    
    /**
     * Default destructor
     */
    virtual ~RelativeLayoutParameter(){};
    
    /**
     * 分配并初始化.
     * @return A initialized LayoutParameter which is marked as "autorelease".
     */
    static RelativeLayoutParameter* create();
    
    /**
     * Sets UIRelativeAlign parameter for LayoutParameter.
     *
     * @see UIRelativeAlign
     *
     * @param UIRelativeAlign
     */
    void setAlign(UIRelativeAlign align);
    
    /**
     * Gets UIRelativeAlign parameter for LayoutParameter.
     *
     * @see UIRelativeAlign
     *
     * @return UIRelativeAlign
     */
    UIRelativeAlign getAlign() const;
    
    /**
     * 为 LayoutParameter 设置一个key.这是相对于 widget named
     *
     * @param name
     */
    void setRelativeToWidgetName(const char* name);
    const char* getRelativeToWidgetName() const;
    
    /**
     * Sets LayoutParameter的相对布局的名称。
     *
     * @param name
     */
    void setRelativeName(const char* name);
    
    /**
     * 获取LayoutParameter的相对布局的名称。
     *
     * @return name
     */
    const char* getRelativeName() const;
protected:
    UIRelativeAlign m_eRelativeAlign;
    std::string m_strRelativeWidgetName;
    std::string m_strRelativeLayoutName;
};

NS_CC_EXT_END

#endif /* defined(__LayoutParameter__) */


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值