AI2 Component
(Version nb184)
|
Public Member Functions | |
Ball (ComponentContainer container) | |
int | Height () |
void | Height (int height) |
void | HeightPercent (int pCent) |
int | Width () |
void | Width (int width) |
void | WidthPercent (int pCent) |
boolean | containsPoint (double qx, double qy) |
void | Radius (int radius) |
int | Radius () |
int | PaintColor () |
void | PaintColor (int argb) |
void | OriginAtCenter (boolean b) |
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) |
void | alarm () |
HandlesEventDispatching | getDispatchDelegate () |
void | onDestroy () |
void | onDelete () |
Protected Member Functions | |
void | onDraw (Canvas canvas) |
Protected Member Functions inherited from com.google.appinventor.components.runtime.Sprite | |
Sprite (ComponentContainer container, Handler handler) | |
Sprite (ComponentContainer container) | |
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) |
abstract void | onDraw (android.graphics.Canvas canvas) |
Protected Member Functions inherited from com.google.appinventor.components.runtime.VisibleComponent | |
VisibleComponent () | |
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 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 |
A round 'sprite' that can be placed on a Canvas, where it can react to touches and drags, interact with other sprites (ImageSprites and other Ball
s) and the edge of the Canvas
, and move according to its property values.
For example, to have a Ball
move 4 pixels toward the top of a Canvas
every 500 milliseconds (half second), you would set the Speed(float) property to 4 [pixels], the Interval(int) property to 500 [milliseconds], the Heading(double) property to 90 [degrees], and the Enabled(boolean) property to true
{:.logic.block}. These and its other properties can be changed at any time.
The difference between a Ball
and an ImageSprite
is that the latter can get its appearance from an image file, while a Ball
's appearance can only be changed by varying its PaintColor(int) and Radius(int) properties.
com.google.appinventor.components.runtime.Ball.Ball | ( | ComponentContainer | container | ) |
boolean com.google.appinventor.components.runtime.Ball.containsPoint | ( | double | qx, |
double | qy | ||
) |
Indicates whether the specified point is contained by this sprite. Subclasses of Sprite that are not rectangular should override this method.
qx | the x-coordinate |
qy | the y-coordinate |
Reimplemented from com.google.appinventor.components.runtime.Sprite.
int com.google.appinventor.components.runtime.Ball.Height | ( | ) |
Height property getter method.
Reimplemented from com.google.appinventor.components.runtime.VisibleComponent.
void com.google.appinventor.components.runtime.Ball.Height | ( | int | height | ) |
Height property setter method.
height | height property used by the layout |
Reimplemented from com.google.appinventor.components.runtime.VisibleComponent.
void com.google.appinventor.components.runtime.Ball.HeightPercent | ( | int | hPercent | ) |
Height property setter method.
This version takes a percentage of the parent component's height as its input.
hPercent | width as a percent of the height of its parent |
Reimplemented from com.google.appinventor.components.runtime.VisibleComponent.
void com.google.appinventor.components.runtime.Ball.MoveTo | ( | double | x, |
double | y | ||
) |
Sets the x
and y
coordinates of the Ball
. If OriginAtCenter(boolean) is true, the center of the Ball
will be placed here. Otherwise, the top left edge of the Ball
will be placed at the specified coordinates.
x | the x-coordinate |
y | the y-coordinate |
Reimplemented from com.google.appinventor.components.runtime.Sprite.
|
protected |
void com.google.appinventor.components.runtime.Ball.OriginAtCenter | ( | boolean | b | ) |
Whether the x- and y-coordinates should represent the center of the Ball
(true
{:.logic.block}) or its left and top edges (false
{:.logic.block}).
Reimplemented from com.google.appinventor.components.runtime.Sprite.
int com.google.appinventor.components.runtime.Ball.PaintColor | ( | ) |
void com.google.appinventor.components.runtime.Ball.PaintColor | ( | int | argb | ) |
int com.google.appinventor.components.runtime.Ball.Radius | ( | ) |
void com.google.appinventor.components.runtime.Ball.Radius | ( | int | radius | ) |
int com.google.appinventor.components.runtime.Ball.Width | ( | ) |
Width property getter method.
Reimplemented from com.google.appinventor.components.runtime.VisibleComponent.
void com.google.appinventor.components.runtime.Ball.Width | ( | int | width | ) |
Width property setter method.
width | width property used by the layout |
Reimplemented from com.google.appinventor.components.runtime.VisibleComponent.
void com.google.appinventor.components.runtime.Ball.WidthPercent | ( | int | wPercent | ) |
Width property setter method.
This version takes a percentage of the parent component's width as its input.
wPercent | width as a percent of its parent |
Reimplemented from com.google.appinventor.components.runtime.VisibleComponent.
double com.google.appinventor.components.runtime.Ball.X | ( | ) |
The horizontal coordinate of the Ball
, increasing as the Ball
moves right. If the property OriginAtCenter(boolean) is true, the coordinate is for the center of the Ball
; otherwise, it is for the leftmost point of the Ball
.
Reimplemented from com.google.appinventor.components.runtime.Sprite.
double com.google.appinventor.components.runtime.Ball.Y | ( | ) |
The vertical coordinate of the Ball
, increasing as the Ball
moves down. If the property OriginAtCenter(boolean) is true, the coordinate is for the center of the Ball
otherwise, it is for the uppermost point of the Ball
.
Reimplemented from com.google.appinventor.components.runtime.Sprite.