package greenfoot.importer.scratch;

import java.math.BigDecimal;
import java.util.List;


| Mirrors the Scratch ScratchSpriteMorph class, which is the equivalent of an actor. | @author neil | public class ScratchSpriteMorph extends ScriptableScratchMorph{ public ScratchSpriteMorph(int version, List<ScratchObject> scratchObjects) { super(ScratchUserObject.SCRATCH_SPRITE_MORPH, version, scratchObjects); } @Override public int fields() { return 9; } @Override protected void constructorContents(StringBuilder acc) { acc.append("GreenfootImage img = getImage();\n"); acc.append("img.scale(") .append(getBounds().getWidth().intValue()) .append(", ") .append(getBounds().getHeight().intValue()) .append(");\n"); } @Override protected String greenfootSuperClass() { return "Actor"; } @Override public ScratchPoint getScaleAmount() { return (ScratchPoint) scratchObjects.get(super.fields() + 1); } public ScratchPoint getGreenfootCentre() { return new ScratchPoint(getBounds().getMiddle().x.subtract( getScaleAmount().x.subtract(new BigDecimal(1)).multiply( getCostume().getRotationCentre().x ) ) ,getBounds().getMiddle().y.subtract( getScaleAmount().y.subtract(new BigDecimal(1)).multiply( getCostume().getRotationCentre().y ) ) ); } @Override protected void addHelpers(StringBuilder acc) { acc.append("private void turn(int angle)\n{\nsetRotation(getRotation() + angle);\n}\n"); acc.append(
top, use, map, class ScratchSpriteMorph

.   ScratchSpriteMorph
.   fields
.   constructorContents
.   greenfootSuperClass
.   getScaleAmount
.   getGreenfootCentre
.   addHelpers




82 neLoCode + 2 LoComm