Exemplo n.º 1
0
 private void createTextField()
 {
     if (mTextField == null)
     {
         mTextField = new AsTextField(mTextBounds.width, mTextBounds.height, "");
         mTextField.setVAlign(AsVAlign.CENTER);
         mTextField.setHAlign(AsHAlign.CENTER);
         mTextField.setTouchable(false);
         mTextField.setAutoScale(true);
         mContents.addChild(mTextField);
     }
     mTextField.setWidth(mTextBounds.width);
     mTextField.setHeight(mTextBounds.height);
     mTextField.setX(mTextBounds.x);
     mTextField.setY(mTextBounds.y);
 }
Exemplo n.º 2
0
 public AsButton(AsTexture upState, String text, AsTexture downState)
 {
     if(upState == null)
     {
         throw new AsArgumentError("Texture cannot be null");
     }
     mUpState = upState;
     mDownState = downState != null ? downState : upState;
     mBackground = new AsImage(upState);
     mScaleWhenDown = downState != null ? 1.0f : 0.9f;
     mAlphaWhenDisabled = 0.5f;
     mEnabled = true;
     mIsDown = false;
     mUseHandCursor = true;
     mTextBounds = new AsRectangle(0, 0, upState.getWidth(), upState.getHeight());
     mContents = new AsSprite();
     mContents.addChild(mBackground);
     addChild(mContents);
     addEventListener(AsTouchEvent.TOUCH, onTouch);
     if(text.Length != 0)
     {
         this.setText(text);
     }
 }
Exemplo n.º 3
0
 public AsButton(AsTexture upState, String text, AsTexture downState)
 {
     if (upState == null)
     {
         throw new AsArgumentError("Texture cannot be null");
     }
     mUpState           = upState;
     mDownState         = downState != null ? downState : upState;
     mBackground        = new AsImage(upState);
     mScaleWhenDown     = downState != null ? 1.0f : 0.9f;
     mAlphaWhenDisabled = 0.5f;
     mEnabled           = true;
     mIsDown            = false;
     mUseHandCursor     = true;
     mTextBounds        = new AsRectangle(0, 0, upState.getWidth(), upState.getHeight());
     mContents          = new AsSprite();
     mContents.addChild(mBackground);
     addChild(mContents);
     addEventListener(AsTouchEvent.TOUCH, onTouch);
     if (text.Length != 0)
     {
         this.setText(text);
     }
 }
 public virtual AsSprite createSprite(float width, float height, String text, float fontSize, uint color, String hAlign, String vAlign, bool autoScale, bool kerning)
 {
     AsVector<AsCharLocation> charLocations = arrangeChars(width, height, text, fontSize, hAlign, vAlign, autoScale, kerning);
     int numChars = (int)(charLocations.getLength());
     AsSprite sprite = new AsSprite();
     int i = 0;
     for (; i < numChars; ++i)
     {
         AsCharLocation charLocation = charLocations[i];
         AsImage _char = charLocation._char.createImage();
         _char.setX(charLocation.x);
         _char.setY(charLocation.y);
         _char.setScaleX(_char.setScaleY(charLocation.scale));
         _char.setColor(color);
         sprite.addChild(_char);
     }
     return sprite;
 }