Calico Sprites

From IPRE Wiki
Revision as of 01:33, 12 July 2013 by Doug Blank (Talk | contribs)

Jump to: navigation, search

Calico Sprites is a library designed to allow the creation of animations. View issues/request features here.

from Sprites import *

init()
s = getSprite("Sprite1")
s.changeCostume("pinkHair")
s.glideForward(30, 1)
s.glideTo(170, 220, 1)

Using the Sprites Module

Error creating thumbnail: Unable to save thumbnail to destination
Error creating thumbnail: Unable to save thumbnail to destination
Error creating thumbnail: Unable to save thumbnail to destination
Error creating thumbnail: Unable to save thumbnail to destination
Error creating thumbnail: Unable to save thumbnail to destination


TODO

Examples

TODO

Sprites tab

containsSprite(string spriteName) - Returns True if the specified Sprite is in the sketch.


getSprite(string spriteName) - Returns the specified Sprite.


init() - Creates a new sketch window if none exists or resets the current sketch window. A default Sprite named "Sprite1" is automatically created and drawn on the left side of the window.


init(bool spritesVisibleOnCreation) - init(True) works the same way as init(). init(False) will create a default Sprite named "Sprite1," but this Sprite will not be automatically drawn to the window. Instead, you may choose when you want the Sprite to appear by using show(). See examples/jigsaw/Sprites/InitDemo.jig for details.


makeSprite() - Creates a new Sprite. It's name will be automatically generated in a "Sprite{number}" format, like "Sprite1," "Sprite2," etc.


makeSprite(string spriteName) - Creates a new Sprite with the specified name.


makeSprite(string spriteName, string filename) - Creates a new Sprite with the specified name. Instead of its default costume being a plain stick figure, its default will be the picture specified by filename (which should be placed in examples/images/SpriteCostumes).


makeSpritesVisibleOnCreation(bool visible) - After setting visible to True, Sprites will automatically be drawn when they are created. Setting visible to False will allow the creation of Sprites, but when made they will not be automatically drawn. See examples/jigsaw/Sprites/InitDemo.jig for details.


printAllSpriteNames() - Prints the names of all the existing Sprites to the console.


printSpriteStatus() - Prints the current Sprite's coordinate position, rotation, and visibility setting to the console.


removeSprite(string spriteName) - Removes the specified Sprite from the sketch.


selectSprite(string spriteName) - Changes the current Sprite (useful when using the Sprites module without dot-notation programming). Also returns the specified Sprite. TODO example here


wait(double seconds) - Pauses for the given amount of seconds. Seconds can be a decimal number.


Sprites Interact tab

imitateSprite(string spriteName) - Makes the current Sprite imitate the specified Sprite when the specified Sprite moves, glides, rotates, scales, flips, and hides/shows. examples/jigsaw/Sprites/DanceParty.jig for details.


stopImitating() - Makes the current Sprite stop imitating the Sprite it was following.


Note: future update will allow multiple Sprites to follow one Sprite, however this version only allows a one-imitates-another format.


Sprites Look tab

addBackground(string filename) - There are automatically two choices landscape/sun but you can add more using this TOODO word better

Sprites.addBackground("stage.png")


addCostume(string filename) - Same as above TODO note only adds to the current Sprite!

Sprites.addCostume("redHair.png")
Sprites.addCostume("goldHair.png")


changeBackground(string backdropName) - TODO note lack of extension

Sprites.changeBackground("stage")


changeCostume(string costumeName) - TODO note lack of extension

Sprites.changeCostume("redHair")


flipHorizontal() - Flips the current Sprite horizontally.


flipVertical() - Flips the current Sprite vertically.


hide() - Undraws the current Sprite from the sketch window. Use show() to make the Sprite reappear.


isVisible() - Returns True if the current Sprite is drawn on the sketch window, returns False otherwise.


show() - Draws the current Sprite on the sketch window. Use hide() to make the Sprite disappear.


Sprites Move tab

backward(double pixels) - Moves the current Sprite backward by the specified number of pixels. (This usually means to the left unless the Sprite has been rotated.)


changeXPositionBy(double pixels) - Changes the current Sprite's X position by the specified number of pixels. TODO example


changeYPositionBy(double pixels) - Changes the current Sprite's X position by the specified number of pixels. TODO example


forward(double pixels) - Moves the current Sprite forward by the specified number of pixels. (This usually means to the right unless the Sprite has been rotated.)


glideBackward(double pixels, double seconds) - Animates the current Sprite to move backwards by the specified number of pixels. This movement will be completed over the specified number of seconds.


glideForward(double pixels, double seconds) - Animates the current Sprite to move forwards by the specified number of pixels. This movement will be completed over the specified number of seconds.


glideTo(double x, double y, double seconds) - Animates the current Sprite to move to the specified (x, y) coordinate. This movement will be completed over the specified number of seconds.


move(double x, double y) - Changes the current Sprite's x position by x and its y position by y. TODO example


moveTo(double x, double y) - Moves the current Sprite to the specified (x, y) coordinate.


rotate(double degrees) - Rotates the current Sprite counter-clockwise by the specified number of degrees.

//Results in a final rotation of 60.

Sprites.rotate(30)
Sprites.rotate(30)


rotateTo(double degrees) - Rotates the current Sprite clockwise to the specified number of degrees.

//Results in a final rotation of 60.

Sprites.rotateTo(-60)
Sprites.rotateTo(-60)


scale(double factor) - Scales the current Sprite by a percent (.1 is 10% of original; 1.1 is 10% larger).


scaleTo(double factor) - Scales the current Sprite to the specified factor (1 is 100% of original).


Note: The origin (0,0) is at the top left of the sketch window. X and Y values increase as you move right and down the sketch window respectively.

Note: Control waits for the glide functions to complete before moving on. Future updates will allow control to continue to the next action before glide completes, letting glide continue to animate in the background.


Sprites Sound tab

play(string filename) - Plays the specified file. Choose from the .wav files in examples/sounds. See examples/python/Sprites/soundDemo.py for a demonstration.


playFor(string filename, double seconds) - Plays the specified file on repeat for the specified number of seconds. Control continues on after the audio file begins playing. See examples/python/Sprites/soundDemo.py for a demonstration.


printVoiceOptions() - Prints all available voice accents.


setVoice(string voiceID) - Sets the current Sprite's voice accent.


speak(string message, double seconds) - Speaks the message while displaying a speech bubble above the current Sprite.