Class BitmapText
java.lang.Object
org.openpatch.scratch.Sprite
org.openpatch.scratch.drawing.DrawingSprite
org.openpatch.scratch.drawing.BitmapText
- All Implemented Interfaces:
Cloneable
Text made from image glyphs, such as font065.png for 'A'. Add it to a stage
like a sprite. Its position is the top of the first line, with each line
aligned left, centred or right. Spaces and line breaks do not load images.
Image data uses the library cache, so changing text does not create sprites
or reload files. Use ordinary Text for normal system/TrueType fonts.
-
Field Summary
Fields inherited from class Sprite
DIRECTION_DOWN, DIRECTION_LEFT, DIRECTION_RIGHT, DIRECTION_UP -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAssigns an image to a special character, such as a controller button.voidDraws the sprite; called every frame on the game thread.doubledoublegetWidth()voidvoidvoidsetLetterSpacing(double spacing) voidsetLineSpacing(double spacing) voidsetSpaceWidth(double width) voidMethods inherited from class Sprite
addAnimation, addAnimation, addAnimation, addCostume, addCostume, addCostume, addCostumes, addSound, addSound, ask, broadcast, changeColorEffect, changeHeight, changePosition, changePosition, changeSize, changeTransparency, changeVolume, changeWidth, changeX, changeY, createClone, debug, deleteThisClone, disableHitbox, disableNineSlice, distanceToMousePointer, distanceToSprite, enableHitbox, extension, getAnimationFrame, getAnimationInterval, getAnswer, getColorEffect, getCurrentCostumeIndex, getCurrentCostumeName, getDirection, getHitbox, getLayer, getMouse, getMouseX, getMouseY, getPen, getPosition, getRotationStyle, getShaders, getSize, getStage, getText, getTimer, getTint, getTouchingSprite, getTouchingSprites, getTransparency, getVolume, getX, getY, glide, goLayersBackwards, goLayersForwards, goToBackLayer, goToFrontLayer, goToMousePointer, goToRandomPosition, goToSprite, hide, hideVariable, ifOnEdgeBounce, isAnimationPlayed, isAsking, isClone, isColorTouchingColor, isGliding, isKeyPressed, isMouseDown, isSoundPlaying, isTouchingColor, isTouchingColor, isTouchingEdge, isTouchingMousePointer, isTouchingSprite, isTouchingSprite, isVisible, move, nextCostume, pickRandom, playAnimation, playAnimation, playSound, playSoundCopy, pointTowards, pointTowards, pointTowardsMousePointer, previousCostume, remove, resetAnimation, run, say, say, setAnimationFrame, setAnimationInterval, setColorEffect, setDirection, setHeight, setHitbox, setLayer, setNineSlice, setPosition, setPosition, setRotationCenter, setRotationStyle, setSize, setTint, setTint, setTransparency, setVolume, setWidth, setX, setY, show, showVariable, stamp, stamp, stopAllSounds, stopSound, switchCostume, switchCostume, think, think, toString, turnLeft, turnRight, whenAddedToStage, whenBackdropSwitches, whenClicked, whenIReceive, whenKeyPressed, whenKeyReleased, whenMouseClicked, whenMouseMoved, whenRemovedFromStage, whenStartsAsClone
-
Constructor Details
-
BitmapText
- Parameters:
pattern- image path with an integer format, e.g. "assets/font%03d.png"
-
-
Method Details
-
showText
- Parameters:
text- text to show, including spaces and newlines
-
getContent
- Returns:
- the text being shown
-
setFont
- Parameters:
pattern- glyph path with one integer format for the Unicode code point
-
addGlyph
Assigns an image to a special character, such as a controller button. Overrides remain in effect when setFont() changes the ordinary glyphs.- Parameters:
character- the character to replacepath- its image or built-in costume name
-
setAlign
- Parameters:
align- LEFT, CENTER or RIGHT (DEFAULT means LEFT)
-
setSpaceWidth
public void setSpaceWidth(double width) - Parameters:
width- width of a space, in unscaled pixels
-
setLetterSpacing
public void setLetterSpacing(double spacing) - Parameters:
spacing- gap between characters; negative values allow italic glyphs to overlap
-
setLineSpacing
public void setLineSpacing(double spacing) - Parameters:
spacing- extra pixels between lines
-
getWidth
-
getHeight
-
draw
Description copied from class:DrawingSpriteDraws the sprite; called every frame on the game thread.- Overrides:
drawin classDrawingSprite- Parameters:
drawing- the current frame's canvas
-