Sprite::getWidth()
Get the width of the sprite.
Examples
import org.openpatch.scratch.*;
public class SpriteGetWidth {
public SpriteGetWidth() {
Stage myStage = new Stage(600, 240);
Sprite mySprite = new Sprite("zeta", "assets/zeta_green_badge.png");
myStage.add(mySprite);
mySprite.changeX(-80);
mySprite.changeY(30);
mySprite.say("Width: " + mySprite.getWidth());
myStage.wait(3000);
myStage.exit();
}
public static void main(String[] args) {
new SpriteGetWidth();
}
}
Syntax
Java
.getWidth()
Scratch
Return
float