AI2 Component  (Version nb184)
com.google.appinventor.components.runtime.ImageSprite Class Reference
Inheritance diagram for com.google.appinventor.components.runtime.ImageSprite:
com.google.appinventor.components.runtime.Sprite com.google.appinventor.components.runtime.VisibleComponent com.google.appinventor.components.runtime.AlarmHandler com.google.appinventor.components.runtime.OnDestroyListener com.google.appinventor.components.runtime.Deleteable com.google.appinventor.components.runtime.Component

Public Member Functions

 ImageSprite (ComponentContainer container)
 
void onDraw (android.graphics.Canvas canvas)
 
String Picture ()
 
void Picture (String path)
 
int Height ()
 
void Height (int height)
 
void HeightPercent (int pCent)
 
int Width ()
 
void Width (int width)
 
void WidthPercent (int pCent)
 
boolean Rotates ()
 
void Rotates (boolean rotates)
 
double X ()
 
double Y ()
 
void MoveTo (double x, double y)
 
- Public Member Functions inherited from com.google.appinventor.components.runtime.Sprite
void Initialize ()
 
boolean Enabled ()
 
void Enabled (boolean enabled)
 
double Heading ()
 
void Heading (double userHeading)
 
int Interval ()
 
void Interval (int interval)
 
void Speed (float speed)
 
float Speed ()
 
boolean Visible ()
 
void Visible (boolean visible)
 
void X (double x)
 
void Y (double y)
 
void Z (double layer)
 
double Z ()
 
void CollidedWith (Sprite other)
 
void Dragged (float startX, float startY, float prevX, float prevY, float currentX, float currentY)
 
void EdgeReached (int edge)
 
void NoLongerCollidingWith (Sprite other)
 
void Touched (float x, float y)
 
void Flung (float x, float y, float speed, float heading, float xvel, float yvel)
 
void TouchUp (float x, float y)
 
void TouchDown (float x, float y)
 
void Bounce (int edge)
 
boolean CollidingWith (Sprite other)
 
void MoveIntoBounds ()
 
void PointTowards (Sprite target)
 
void PointInDirection (double x, double y)
 
BoundingBox getBoundingBox (int border)
 
boolean intersectsWith (BoundingBox rect)
 
boolean containsPoint (double qx, double qy)
 
void alarm ()
 
HandlesEventDispatching getDispatchDelegate ()
 
void onDestroy ()
 
void onDelete ()
 

Additional Inherited Members

- Static Public Member Functions inherited from com.google.appinventor.components.runtime.Sprite
static boolean colliding (Sprite sprite1, Sprite sprite2)
 
- Static Public Attributes inherited from com.google.appinventor.components.runtime.Component
static final String ASSET_DIRECTORY = "component"
 
static final int ALIGNMENT_NORMAL = 0
 
static final int ALIGNMENT_CENTER = 1
 
static final int ALIGNMENT_OPPOSITE = 2
 
static final int ACCELEROMETER_SENSITIVITY_WEAK = 1
 
static final int ACCELEROMETER_SENSITIVITY_MODERATE = 2
 
static final int ACCELEROMETER_SENSITIVITY_STRONG = 3
 
static final int BUTTON_SHAPE_DEFAULT = 0
 
static final int BUTTON_SHAPE_ROUNDED = 1
 
static final int BUTTON_SHAPE_RECT = 2
 
static final int BUTTON_SHAPE_OVAL = 3
 
static final int COLOR_NONE = 0x00FFFFFF
 
static final int COLOR_BLACK = 0xFF000000
 
static final int COLOR_BLUE = 0xFF0000FF
 
static final int COLOR_CYAN = 0xFF00FFFF
 
static final int COLOR_DKGRAY = 0xFF444444
 
static final int COLOR_GRAY = 0xFF888888
 
static final int COLOR_GREEN = 0xFF00FF00
 
static final int COLOR_LTGRAY = 0xFFCCCCCC
 
static final int COLOR_MAGENTA = 0xFFFF00FF
 
static final int COLOR_ORANGE = 0xFFFFC800
 
static final int COLOR_PINK = 0xFFFFAFAF
 
static final int COLOR_RED = 0xFFFF0000
 
static final int COLOR_WHITE = 0xFFFFFFFF
 
static final int COLOR_YELLOW = 0xFFFFFF00
 
static final int COLOR_DEFAULT = 0x00000000
 
static final String DEFAULT_VALUE_COLOR_NONE = "&H00FFFFFF"
 
static final String DEFAULT_VALUE_COLOR_BLACK = "&HFF000000"
 
static final String DEFAULT_VALUE_COLOR_BLUE = "&HFF0000FF"
 
static final String DEFAULT_VALUE_COLOR_CYAN = "&HFF00FFFF"
 
static final String DEFAULT_VALUE_COLOR_DKGRAY = "&HFF444444"
 
static final String DEFAULT_VALUE_COLOR_GRAY = "&HFF888888"
 
static final String DEFAULT_VALUE_COLOR_GREEN = "&HFF00FF00"
 
static final String DEFAULT_VALUE_COLOR_LTGRAY = "&HFFCCCCCC"
 
static final String DEFAULT_VALUE_COLOR_MAGENTA = "&HFFFF00FF"
 
static final String DEFAULT_VALUE_COLOR_ORANGE = "&HFFFFC800"
 
static final String DEFAULT_VALUE_COLOR_PINK = "&HFFFFAFAF"
 
static final String DEFAULT_VALUE_COLOR_RED = "&HFFFF0000"
 
static final String DEFAULT_VALUE_COLOR_WHITE = "&HFFFFFFFF"
 
static final String DEFAULT_VALUE_COLOR_YELLOW = "&HFFFFFF00"
 
static final String DEFAULT_VALUE_COLOR_DEFAULT = "&H00000000"
 
static final float FONT_DEFAULT_SIZE = 14
 
static final int LAYOUT_ORIENTATION_HORIZONTAL = ComponentConstants.LAYOUT_ORIENTATION_HORIZONTAL
 
static final int LAYOUT_ORIENTATION_VERTICAL = ComponentConstants.LAYOUT_ORIENTATION_VERTICAL
 
static final int SCALING_SCALE_PROPORTIONALLY = 0
 
static final int SCALING_SCALE_TO_FIT = 1
 
static final int TYPEFACE_DEFAULT = 0
 
static final int TYPEFACE_SANSSERIF = 1
 
static final int TYPEFACE_SERIF = 2
 
static final int TYPEFACE_MONOSPACE = 3
 
static final int LENGTH_PREFERRED = -1
 
static final int LENGTH_FILL_PARENT = -2
 
static final int LENGTH_UNKNOWN = -3
 
static final int LENGTH_PERCENT_TAG = -1000
 
static final int TOAST_LENGTH_SHORT = 0
 
static final int TOAST_LENGTH_LONG = 1
 
static final int DIRECTION_NORTH = 1
 
static final int DIRECTION_NORTHEAST = 2
 
static final int DIRECTION_EAST = 3
 
static final int DIRECTION_SOUTHEAST = 4
 
static final int DIRECTION_SOUTH = -1
 
static final int DIRECTION_SOUTHWEST = -2
 
static final int DIRECTION_WEST = -3
 
static final int DIRECTION_NORTHWEST = -4
 
static final int DIRECTION_NONE = 0
 
static final int DIRECTION_MIN = -4
 
static final int DIRECTION_MAX = 4
 
static float SLIDER_MIN_VALUE = 10
 
static float SLIDER_MAX_VALUE = 50
 
static float SLIDER_THUMB_VALUE = (SLIDER_MIN_VALUE + SLIDER_MAX_VALUE) / 2.0f
 
static final String DEFAULT_VALUE_TEXT_TO_SPEECH_COUNTRY = ""
 
static final String DEFAULT_VALUE_TEXT_TO_SPEECH_LANGUAGE = ""
 
- Protected Member Functions inherited from com.google.appinventor.components.runtime.Sprite
 Sprite (ComponentContainer container, Handler handler)
 
 Sprite (ComponentContainer container)
 
void OriginAtCenter (boolean b)
 
void postEvent (final Sprite sprite, final String eventName, final Object... args)
 
void registerChange ()
 
int hitEdge ()
 
final void moveIntoBounds (int canvasWidth, int canvasHeight)
 
void updateCoordinates ()
 
int hitEdge (int canvasWidth, int canvasHeight)
 
- Protected Member Functions inherited from com.google.appinventor.components.runtime.VisibleComponent
 VisibleComponent ()
 
- Protected Attributes inherited from com.google.appinventor.components.runtime.Sprite
final Canvas canvas
 
boolean initialized = false
 
int interval
 
boolean visible = true
 
double xLeft
 
double yTop
 
double zLayer
 
float speed
 
boolean originAtCenter
 
double xCenter
 
double yCenter
 
Form form
 
double userHeading
 
double heading
 
double headingRadians
 
double headingCos
 
double headingSin
 
- Static Protected Attributes inherited from com.google.appinventor.components.runtime.Sprite
static final boolean DEFAULT_ORIGIN_AT_CENTER = false
 

Detailed Description

A 'sprite' that can be placed on a Canvas, where it can react to touches and drags, interact with other sprites (Balls and other ImageSprites) and the edge of the Canvas, and move according to its property values. Its appearance is that of the image specified in its Picture() property (unless its Visible() property is false{:.logic.block}.

To have an ImageSprite move 10 pixels to the left every 1000 milliseconds (one second), for example, you would set the Speed() property to 10 [pixels], the Interval() property to 1000 [milliseconds], the Heading() property to 180 [degrees], and the Enabled() property to true{:.logic.block}. A sprite whose Rotates() property is true{:.logic.block} will rotate its image as the sprite's heading changes. Checking for collisions with a rotated sprite currently checks the sprite's unrotated position so that collision checking will be inaccurate for tall narrow or short wide sprites that are rotated. Any of the sprite properties can be changed at any time under program control.

Definition at line 66 of file ImageSprite.java.

Constructor & Destructor Documentation

◆ ImageSprite()

com.google.appinventor.components.runtime.ImageSprite.ImageSprite ( ComponentContainer  container)

Constructor for ImageSprite.

Parameters
container

Definition at line 80 of file ImageSprite.java.

Member Function Documentation

◆ Height() [1/2]

int com.google.appinventor.components.runtime.ImageSprite.Height ( )

Height property getter method.

Returns
height property used by the layout

Reimplemented from com.google.appinventor.components.runtime.VisibleComponent.

Definition at line 157 of file ImageSprite.java.

◆ Height() [2/2]

void com.google.appinventor.components.runtime.ImageSprite.Height ( int  height)

@suppressdoc

Parameters
heightheight property used by the layout

Reimplemented from com.google.appinventor.components.runtime.VisibleComponent.

Definition at line 171 of file ImageSprite.java.

◆ HeightPercent()

void com.google.appinventor.components.runtime.ImageSprite.HeightPercent ( int  hPercent)

Height property setter method.

This version takes a percentage of the parent component's height as its input.

Parameters
hPercentwidth as a percent of the height of its parent

Reimplemented from com.google.appinventor.components.runtime.VisibleComponent.

Definition at line 177 of file ImageSprite.java.

◆ MoveTo()

void com.google.appinventor.components.runtime.ImageSprite.MoveTo ( double  x,
double  y 
)

Moves the type% so that its left top corner is at the specified x and y coordinates.

Parameters
xthe x-coordinate
ythe y-coordinate

Reimplemented from com.google.appinventor.components.runtime.Sprite.

Definition at line 263 of file ImageSprite.java.

◆ onDraw()

void com.google.appinventor.components.runtime.ImageSprite.onDraw ( android.graphics.Canvas  canvas)

This method uses getWidth and getHeight directly from the bitmap, so we apply corrections for density for coordinates and size.

Parameters
canvasthe canvas on which to draw

Reimplemented from com.google.appinventor.components.runtime.Sprite.

Definition at line 91 of file ImageSprite.java.

◆ Picture() [1/2]

String com.google.appinventor.components.runtime.ImageSprite.Picture ( )

Returns the path of the sprite's picture

Returns
the path of the sprite's picture

Definition at line 124 of file ImageSprite.java.

◆ Picture() [2/2]

void com.google.appinventor.components.runtime.ImageSprite.Picture ( String  path)

Specifies the path of the sprite's picture.

@internaldoc

See MediaUtil#determineMediaSource for information about what a path can be.

Parameters
paththe path of the sprite's picture

Definition at line 140 of file ImageSprite.java.

◆ Rotates() [1/2]

boolean com.google.appinventor.components.runtime.ImageSprite.Rotates ( )

Rotates property getter method.

Returns
true
indicates that the image rotates to match the sprite's heading
false
indicates that the sprite image doesn't rotate.

Definition at line 217 of file ImageSprite.java.

◆ Rotates() [2/2]

void com.google.appinventor.components.runtime.ImageSprite.Rotates ( boolean  rotates)

If true, the sprite image rotates to match the sprite's heading. If false, the sprite image does not rotate when the sprite changes heading. The sprite rotates around its centerpoint.

Parameters
rotates

Definition at line 231 of file ImageSprite.java.

◆ Width() [1/2]

int com.google.appinventor.components.runtime.ImageSprite.Width ( )

Width property getter method.

Returns
width property used by the layout

Reimplemented from com.google.appinventor.components.runtime.VisibleComponent.

Definition at line 183 of file ImageSprite.java.

◆ Width() [2/2]

void com.google.appinventor.components.runtime.ImageSprite.Width ( int  width)

@suppressdoc

Parameters
widthwidth property used by the layout

Reimplemented from com.google.appinventor.components.runtime.VisibleComponent.

Definition at line 197 of file ImageSprite.java.

◆ WidthPercent()

void com.google.appinventor.components.runtime.ImageSprite.WidthPercent ( int  wPercent)

Width property setter method.

This version takes a percentage of the parent component's width as its input.

Parameters
wPercentwidth as a percent of its parent

Reimplemented from com.google.appinventor.components.runtime.VisibleComponent.

Definition at line 203 of file ImageSprite.java.

◆ X()

double com.google.appinventor.components.runtime.ImageSprite.X ( )

Reimplemented from com.google.appinventor.components.runtime.Sprite.

Definition at line 242 of file ImageSprite.java.

◆ Y()

double com.google.appinventor.components.runtime.ImageSprite.Y ( )

Reimplemented from com.google.appinventor.components.runtime.Sprite.

Definition at line 250 of file ImageSprite.java.


The documentation for this class was generated from the following file: