Example #1
0
var Label = function(options){
    Widget.call( this, options );

    
    this._pTextLable = new UIText();
    this._pTextLable.init();
    
    this._nGravity = options.gravity || 0;

    switch (this._nGravity){
        case 0:
        this._pTextLable.setAnchorPoint({x:0.5,y:0.5});
        break;
        case 1:
        this._pTextLable.setAnchorPoint({x:0.0,y:0.5});
        break;
        case 2:
        this._pTextLable.setAnchorPoint({x:1.0,y:0.5});
        break;
    }

    this._bTouchScaleChangeAble = options.touchSacleEnable || false;
    this._fOnSelectedScaleOffset = options.scaleOffset || 0.5;

    this._text = options.text || 'label';
    this.setText(options.text);

    this._nFontSize = options.fontSize || 20;
    this.setFontSize( this._nFontSize );

    this._sFontName = options.fontName || "宋体";
    this.setFontName( this._sFontName );

    this.setTextColor( this._nColorR, this._nColorG, this._nColorB );
                      
    if ( options.flipX ){
        this.setFlipX(options.flipX);
    }
    if ( options.flipY ){
        this.setFlipY(options.flipY);
    }

    this.addUIElement(this._pTextLable);
    this.setPressState(0);
 };
Example #2
0
var CheckBox = function(options){
    Widget.call( this, options );

    this._pBackGroundBox = null;
    this._pBackGroundSelectedBox = null;
    this._pFrontCross = null;
    this._bIsSelected = options.state || false;
    
    //Events
    if( options.scriptJS ){
        this.events = {
            onSelected: options.scriptJS[options.onSelected] , 
            onUnSelected: options.scriptJS[options.onUnSelected]
        };
    }
    else{
        this.events = {};
    }

    this.backGroundBoxImageFileName = options.backGroundBox;
    this.backGroundSelectedBoxFileName = options.backGroundBoxSelected;
    this.frontCrossImageFileName = options.frontCross;

    this._pBackGroundBox = new UISprite();
    this._pBackGroundBox.init();
    this._pBackGroundBox.loadTexture( this.backGroundBoxImageFileName );

    this._pBackGroundSelectedBox = new UISprite();
    this._pBackGroundSelectedBox.init();
    this._pBackGroundSelectedBox.loadTexture(this.backGroundSelectedBoxFileName);

    this._pFrontCross = new UISprite();
    this._pFrontCross.init();
    this._pFrontCross.loadTexture(this.frontCrossImageFileName);

    this.addUIElement(this._pBackGroundBox);
    this.addUIElement(this._pBackGroundSelectedBox);
    this.addUIElement(this._pFrontCross);
    this.setPressState(0);
    this.setSelectedState( this._bIsSelected );
 };