Skip to content

TweenPlayer

Plays a little animation of how its entity is drawn, with no code: grown or shrunk (Scale), moved (Move), turned (Rotate) and faded (Fade) at once, eased, as it appears (OnStart), when its Message is sent, or from a script with Play. A card popping into place, a stamp landing on a page, a score jumping as it changes, a coin bobbing. What’s inside the entity moves and fades with it.

Only how it’s drawn changes: its transform, collider and clickable area stay where they are, so it can’t knock anything over or walk off its place. It plays in real time, held while the game is paused unless it’s on an open panel, so a pause menu’s buttons can pop in. It plays on every player’s machine, from what’s sent to it.

Changes how its entity is drawn (a tint, a shake or drawing it on top).

Each is listed as its key in the scene file and the MCP tools, then its kind of value, its default and what it does.

  • scale: a number = 0. How big it’s drawn at the far end of the tween, times its own size: 0 grows out of nothing, 2 lands from twice its size, 1.3 a pop that settles, 1 keeps its size. (Field: a number.)
  • move: [x, y] = [0,0]. How far off its place it’s drawn at the far end, in world units: (0, 1) drops in from a unit above. (Field: a vector.)
  • rotate: a number = 0. How far it’s turned at the far end, in degrees (counterclockwise): 360 spins it once round. (Field: a number.)
  • fade: a number = 0. How faded it’s drawn at the far end, from 0 (not at all) to 1 (gone): 1 fades it in, or out with To. (Field: a number.)
  • direction: one of From, To = “From”. From (the default) starts at the far end and settles to how the entity is; To goes from how it is to the far end and stays there once it ends (until it’s played again or stopped). (Field: one of its values.)
  • duration: a number = 0.3. Seconds it takes from one end to the other. (Field: a number.)
  • delay: a number = 0. Seconds it waits before it moves, once set off (held at its start meanwhile): cards appearing one after another. (Field: a number.)
  • ease: one of Linear, InQuad, OutQuad, InOutQuad, InCubic, OutCubic, InOutCubic, InOutSine, InBack, OutBack, OutElastic, OutBounce = “OutBack”. The curve it moves along: Out Back overshoots a little and settles, Out Bounce lands like a dropped ball, Linear keeps one speed. (Field: one of its values.)
  • loop: one of Once, Repeat, PingPong = “Once”. Once, or over and over: Repeat starts again from the start, Ping Pong goes back and forth. (Field: one of its values.)
  • onStart: true or false = true. Plays it whenever the entity appears: as the scene starts, as it’s spawned, and each time it’s shown again. (Field: on or off.)
  • message: text = null. The message that plays it (from the start), e.g. “Scored”. Empty plays it only on start, or from a script. (Names a message.) (Field: a name.)

What anything can make it do with no code: a Trigger’s do when its message arrives, a Contraptions Wire’s input as its signal comes on, a script’s Game.Do(entity, “Name”).

  • Play. Plays it from the start, even if it’s playing now.
  • Stop. Stops it, and it’s drawn as the entity is.

Not saved with the scene; scripts read them, and entity_get shows them as live while the game plays.

  • isPlaying: true or false. True while it’s playing (a looping one, until it’s stopped).
  • amount: a number. How far it’s drawn towards the far end now, from 0 (as the entity is) to 1 (as its values say); an overshooting Ease takes it a little past either end.

Scripts use it as TweenPlayer: its methods, events and values that aren’t saved with the scene.