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;
 }
 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);
     }
 }
Beispiel #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);
     }
 }