Scratch für Java

Sprite::setSize()

Setzt die Größe der Figur in Prozent.

You this methode wisely, since it is slow. If you want to resize a sprite just once, consider reducing the size of the original image.

Beispiele

import org.openpatch.scratch.Sprite;
import org.openpatch.scratch.Stage;
 
public class SpriteSetSize {
  public SpriteSetSize() {
    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("Size: " + mySprite.getSize());
    myStage.wait(2000);
    mySprite.setSize(50);
    mySprite.say("Size: " + mySprite.getSize());
    myStage.wait(2000);
    myStage.exit();
  }
 
  public static void main(String[] args) {
    new SpriteSetSize();
  }
}
 

Auf GitHub anschauen

Syntax

Java

.setSize(percentage)

Scratch

set size to (50) %

Parameter

Name Datentyp Beschreibung
percentage float Ein Wert in Prozent.

Rückgabe

void

setSize()