Class CardActor

java.lang.Object
com.badlogic.gdx.scenes.scene2d.Actor
com.badlogic.gdx.scenes.scene2d.ui.Widget
com.badlogic.gdx.scenes.scene2d.ui.Image
com.csse3200.game.components.cards.CardActor
All Implemented Interfaces:
com.badlogic.gdx.scenes.scene2d.utils.Layout

public class CardActor extends com.badlogic.gdx.scenes.scene2d.ui.Image
可拖拽卡牌:尺寸/位置用“百分比”记忆,窗口变化时自适应缩放但相对位置不变。
  • Constructor Summary

    Constructors
    Constructor
    Description
    CardActor(com.badlogic.gdx.scenes.scene2d.Stage stage, com.badlogic.gdx.graphics.g2d.TextureRegion region)
    用 TextureRegion 构造(一般从 atlas region 来)。
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    act(float delta)
    每帧检查舞台尺寸变化,变化则重算尺寸与位置。
    static CardActor
    fromAtlas(com.badlogic.gdx.scenes.scene2d.Stage stage, com.badlogic.gdx.graphics.g2d.TextureAtlas atlas, String regionName)
    从 atlas 的 region 创建(推荐)。
    void
    setPercentPosition(float px, float py)
    设置中心点的相对位置(0~1)。
    void
    setPercentWidth(float p)
    调整宽度占比(0.05~0.25 更安全)。

    Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Image

    draw, getAlign, getDrawable, getImageHeight, getImageWidth, getImageX, getImageY, getMinHeight, getMinWidth, getPrefHeight, getPrefWidth, layout, setAlign, setDrawable, setDrawable, setScaling, toString

    Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Widget

    getMaxHeight, getMaxWidth, invalidate, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, sizeChanged, validate

    Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor

    addAction, addCaptureListener, addListener, ancestorsVisible, ascendantsVisible, clear, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, drawDebug, drawDebugBounds, fire, firstAscendant, getActions, getCaptureListeners, getColor, getDebug, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getUserObject, getWidth, getX, getX, getY, getY, getZIndex, hasActions, hasKeyboardFocus, hasParent, hasScrollFocus, hit, isAscendantOf, isDescendantOf, isTouchable, isTouchFocusListener, isTouchFocusTarget, isVisible, localToActorCoordinates, localToAscendantCoordinates, localToParentCoordinates, localToScreenCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, positionChanged, remove, removeAction, removeCaptureListener, removeListener, rotateBy, rotationChanged, scaleBy, scaleBy, scaleChanged, screenToLocalCoordinates, setBounds, setColor, setColor, setDebug, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setParent, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setStage, setTouchable, setUserObject, setVisible, setWidth, setX, setX, setY, setY, setZIndex, sizeBy, sizeBy, stageToLocalCoordinates, toBack, toFront

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • CardActor

      public CardActor(com.badlogic.gdx.scenes.scene2d.Stage stage, com.badlogic.gdx.graphics.g2d.TextureRegion region)
      用 TextureRegion 构造(一般从 atlas region 来)。
  • Method Details

    • fromAtlas

      public static CardActor fromAtlas(com.badlogic.gdx.scenes.scene2d.Stage stage, com.badlogic.gdx.graphics.g2d.TextureAtlas atlas, String regionName)
      从 atlas 的 region 创建(推荐)。
    • setPercentWidth

      public void setPercentWidth(float p)
      调整宽度占比(0.05~0.25 更安全)。
    • setPercentPosition

      public void setPercentPosition(float px, float py)
      设置中心点的相对位置(0~1)。
    • act

      public void act(float delta)
      每帧检查舞台尺寸变化,变化则重算尺寸与位置。
      Overrides:
      act in class com.badlogic.gdx.scenes.scene2d.Actor