0:01 / 0:30
Playback speed

Pivot

Switch the pivot while watching one foot. Which setting keeps it planted as the body tilts?

Interactive demo#SpritesAndImages#Sprite

The point on a sprite that its position, rotation and scale are measured from.

Put the pivot at the feet and the character stands on the ground however you scale or tilt it. Put it in the centre and it spins like a coin. Turn the toggle off to see the feet swing through the floor.

Code

src/demos/pivot.goose
namespace pivot_lesson;
import stage;
import std;
import math;

export "pivot" fn draw(time: f64, dt: f64, px: f64, py: f64, hover: bool) {
    artwork("hall", 0, 0, W, 125);
    ground();
    let feet = toggle("feet");
    let y = if feet { GY } else { GY - 24 };
    let origin_y = if feet { 12 } else { 6 };
    sprite(0, 80, y, 4, 4, "base", "plain", sin(time * 2.2) * 0.7, 6, origin_y, false);
    ring(80, y, 6, MAG);
    cross(80, y, MAG, 4);
}

Stage drawing helpers · All demos on GitHub

Comments

No comments yet.