From 15b361f6a93763f96bd3363c23a5dd4db8160cb2 Mon Sep 17 00:00:00 2001 From: Owen Butler Date: Sun, 19 Sep 2021 21:57:27 +1000 Subject: docs: Update sprite class example with attr_sprite --- docs/todo/05-sprites.md | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'docs/todo/05-sprites.md') diff --git a/docs/todo/05-sprites.md b/docs/todo/05-sprites.md index e8030ab..e2be250 100644 --- a/docs/todo/05-sprites.md +++ b/docs/todo/05-sprites.md @@ -179,26 +179,14 @@ args.outputs.sprites << { ## Duck Typing (Advanced) -You can also create a class with sprite properties and render it as a primitive. -ALL properties must on the class. ADDITIONALLY, a method called `primitive_marker` -must be defined on the class. +You can also create a class with sprite properties and render it as a primitive, +using the `attr_sprite` helper. Here is an example: ```ruby -# Create type with ALL sprite properties AND primitive_marker -class Sprite - attr_accessor :x, :y, :w, :h, :path, :angle, :a, :r, :g, :b, :source_x, - :source_y, :source_w, :source_h, :flip_horizontally, - :flip_vertically, :angle_anchor_x, :angle_anchor_y - - def primitive_marker - :sprite - end -end - -# Inherit from type -class PlayerSprite < Sprite +class PlayerSprite + attr_sprite # constructor def initialize x, y, w, h -- cgit v1.2.3