From 8ba99e63f4fa334972654909c552b81784274187 Mon Sep 17 00:00:00 2001
From: Eric Lewis Fields
Methods
Methods
noblesprite:init([__view[, __viewIsSpritesheet=false[, __singleState=false[, __singleStateLoop=true]]]])
NobleSprite() (see usage examples).
+ Do not call an "init" method directly. Use NobleSprite() (see usage examples).
NOTE: When __view is the path to an image file, or a Graphics.image object, the sprite's size is set automatically via setImage(). When __view is the path to a spritesheet/imagetable file, or a Noble.Animation object, the sprite's size is not set automatically. You must call setSize(width, height) with the dimensions of a single animation frame, or the sprite will never be drawn.
-- Provide a spritesheet image file to create a new Noble.Animation for a NobleSprite's view. -myNobleSprite = NobleSprite("path/to/spritesheet", true)+-- Sprites with animation views do not have their size set automatically, +-- so call setSize() with the dimensions of a single frame. +myNobleSprite = NobleSprite("path/to/spritesheet", true) +myNobleSprite:setSize(32, 32)
-- Provide an image file to create a new Graphics.image for a NobleSprite's view.
myNobleSprite = NobleSprite("path/to/image")
-- Use an existing Noble.Animation for a NobleSprite's view. local myAnimation = Noble.Animation.new("path/to/spritesheet") myAnimation:addState("default", 1, animation.imageTable:getLength(), nil, true) -myNobleSprite = NobleSprite(myAnimation)+myNobleSprite = NobleSprite(myAnimation) +myNobleSprite:setSize(32, 32) -- The dimensions of a single frame.
-- Use an existing Graphics.image object for a NobleSprite's view.
local myImage = Graphics.image.new("path/to/image")
myNobleSprite = NobleSprite(myImage)
@@ -170,12 +177,35 @@ This method is the sprite's draw callback (see playdate.graphics.sprite:draw() in the Playdate SDK), which is invoked by Graphics.sprite.update() whenever this sprite is marked dirty. It runs in sprite-local coordinates, where (0, 0) is the top-left corner of the sprite's bounds, so calling it manually will not draw this sprite at its position in the scene.
To draw an animation directly to the screen without adding a sprite to the scene ("immediate mode"), use myNobleSprite.animation:draw(x, y) instead. To place an animated NobleSprite in a scene, use setSize() and add(x, y).
+
+
+
+
+
NOTE: When using a Noble.Animation as the view for a NobleSprite, the sprite's size is not set automatically; call the sprite's setSize() method with the dimensions of a single animation frame.