← Wszystkie przykłady

Głodny kotek

Owoce do koszyka, zabawki zostają. Kotek mruga (animacja z arkusza klatek), a po rozwiązaniu cieszy się: akcja set-state zmienia jego arkusz na radosny.

Schemat
v2.0
Wymagane funkcje
element.imageelement.textelement.componentelement.targetvisual.textvisual.animationvisual.statescomponent.draggabletarget.capacitytarget.snaprule.placeaction.play-soundaction.lockaction.returnaction.emit-particlesaction.set-state
Componenty
imagetexttargetcomponent

Jak otworzyć w edytorze

  1. Kliknij Otwórz w edytorze — GS Editor otworzy się z wczytanym ćwiczeniem (scena i zasoby).
  2. Albo kliknij Pobierz ćwiczenie (ZIP z projekt.json, images/ i sounds/) i w oknie startowym edytora wybierz Otwórz ZIP.

Plik ćwiczenia

Pokaż JSON (8975 znaków)
{
  "schema": "2.0",
  "requires": [
    "element.image",
    "element.text",
    "element.component",
    "element.target",
    "visual.text",
    "visual.animation",
    "visual.states",
    "component.draggable",
    "target.capacity",
    "target.snap",
    "rule.place",
    "action.play-sound",
    "action.lock",
    "action.return",
    "action.emit-particles",
    "action.set-state"
  ],
  "id": "reacting-character",
  "size": {
    "width": 1200,
    "height": 675
  },
  "languages": [
    "pl",
    "en"
  ],
  "defaultLanguage": "pl",
  "assets": [
    {
      "id": "meadow",
      "kind": "image",
      "src": {
        "default": "images/meadow.png"
      }
    },
    {
      "id": "basket",
      "kind": "image",
      "src": {
        "default": "images/basket.png"
      }
    },
    {
      "id": "strawberry",
      "kind": "image",
      "src": {
        "default": "images/strawberry.png"
      }
    },
    {
      "id": "orange",
      "kind": "image",
      "src": {
        "default": "images/orange.png"
      }
    },
    {
      "id": "pear",
      "kind": "image",
      "src": {
        "default": "images/pear.png"
      }
    },
    {
      "id": "cherries",
      "kind": "image",
      "src": {
        "default": "images/cherries.png"
      }
    },
    {
      "id": "ball",
      "kind": "image",
      "src": {
        "default": "images/ball.png"
      }
    },
    {
      "id": "block",
      "kind": "image",
      "src": {
        "default": "images/block.png"
      }
    },
    {
      "id": "cat-blink",
      "kind": "animation",
      "src": {
        "default": "images/cat-blink.png"
      }
    },
    {
      "id": "cat-joy",
      "kind": "animation",
      "src": {
        "default": "images/cat-joy.png"
      }
    },
    {
      "id": "correct",
      "kind": "audio",
      "src": {
        "default": "sounds/correct.wav"
      }
    },
    {
      "id": "wrong",
      "kind": "audio",
      "src": {
        "default": "sounds/wrong.wav"
      }
    },
    {
      "id": "pick-up",
      "kind": "audio",
      "src": {
        "default": "sounds/pick-up.wav"
      }
    },
    {
      "id": "drop",
      "kind": "audio",
      "src": {
        "default": "sounds/drop.wav"
      }
    },
    {
      "id": "win",
      "kind": "audio",
      "src": {
        "default": "sounds/win.wav"
      }
    }
  ],
  "elements": [
    {
      "id": "background",
      "type": "image",
      "rect": [
        0,
        0,
        1200,
        675
      ],
      "layer": 0,
      "visual": {
        "type": "image",
        "asset": "meadow"
      }
    },
    {
      "id": "instruction",
      "type": "text",
      "rect": [
        72,
        20,
        1056,
        80
      ],
      "layer": 5,
      "visual": {
        "type": "text",
        "text": {
          "pl": "Kotek jest głodny. Włóż do <b>koszyka</b> wszystkie owoce i zobacz, jak się ucieszy!",
          "en": "The kitten is hungry. Put all the fruit in the <b>basket</b> and see how happy it gets!"
        },
        "size": 28,
        "color": "#5a3a22",
        "align": "center"
      }
    },
    {
      "id": "kitten",
      "type": "image",
      "rect": [
        860,
        280,
        280,
        280
      ],
      "layer": 2,
      "visual": {
        "type": "animation",
        "asset": "cat-blink",
        "frames": 4,
        "fps": 3,
        "loop": true,
        "autoplay": true,
        "states": {
          "smile": {
            "asset": "cat-joy",
            "frames": 4,
            "fps": 8,
            "loop": true,
            "autoplay": true
          }
        }
      }
    },
    {
      "id": "basket",
      "type": "target",
      "rect": [
        435,
        300,
        300,
        270
      ],
      "layer": 1,
      "visual": {
        "type": "image",
        "asset": "basket"
      },
      "capacity": "many",
      "snap": {
        "mode": "none"
      },
      "on": {
        "correct": [
          {
            "do": "play-sound",
            "asset": "correct"
          },
          {
            "do": "lock",
            "target": "dropped"
          },
          {
            "do": "emit-particles",
            "target": "dropped"
          }
        ],
        "wrong": [
          {
            "do": "play-sound",
            "asset": "wrong"
          },
          {
            "do": "return",
            "target": "dropped"
          }
        ]
      }
    },
    {
      "id": "strawberry",
      "type": "component",
      "rect": [
        60,
        140,
        100,
        100
      ],
      "layer": 3,
      "visual": {
        "type": "image",
        "asset": "strawberry"
      },
      "draggable": {
        "bounds": "scene",
        "hit": "pixels"
      },
      "on": {
        "drag-start": [
          {
            "do": "play-sound",
            "asset": "pick-up"
          }
        ],
        "drop-outside": [
          {
            "do": "play-sound",
            "asset": "drop"
          },
          {
            "do": "return",
            "target": "self"
          }
        ]
      }
    },
    {
      "id": "ball",
      "type": "component",
      "rect": [
        210,
        140,
        100,
        100
      ],
      "layer": 3,
      "visual": {
        "type": "image",
        "asset": "ball"
      },
      "draggable": {
        "bounds": "scene",
        "hit": "pixels"
      },
      "on": {
        "drag-start": [
          {
            "do": "play-sound",
            "asset": "pick-up"
          }
        ],
        "drop-outside": [
          {
            "do": "play-sound",
            "asset": "drop"
          },
          {
            "do": "return",
            "target": "self"
          }
        ]
      }
    },
    {
      "id": "orange",
      "type": "component",
      "rect": [
        60,
        300,
        100,
        100
      ],
      "layer": 3,
      "visual": {
        "type": "image",
        "asset": "orange"
      },
      "draggable": {
        "bounds": "scene",
        "hit": "pixels"
      },
      "on": {
        "drag-start": [
          {
            "do": "play-sound",
            "asset": "pick-up"
          }
        ],
        "drop-outside": [
          {
            "do": "play-sound",
            "asset": "drop"
          },
          {
            "do": "return",
            "target": "self"
          }
        ]
      }
    },
    {
      "id": "pear",
      "type": "component",
      "rect": [
        210,
        300,
        100,
        100
      ],
      "layer": 3,
      "visual": {
        "type": "image",
        "asset": "pear"
      },
      "draggable": {
        "bounds": "scene",
        "hit": "pixels"
      },
      "on": {
        "drag-start": [
          {
            "do": "play-sound",
            "asset": "pick-up"
          }
        ],
        "drop-outside": [
          {
            "do": "play-sound",
            "asset": "drop"
          },
          {
            "do": "return",
            "target": "self"
          }
        ]
      }
    },
    {
      "id": "block",
      "type": "component",
      "rect": [
        60,
        460,
        100,
        100
      ],
      "layer": 3,
      "visual": {
        "type": "image",
        "asset": "block"
      },
      "draggable": {
        "bounds": "scene",
        "hit": "pixels"
      },
      "on": {
        "drag-start": [
          {
            "do": "play-sound",
            "asset": "pick-up"
          }
        ],
        "drop-outside": [
          {
            "do": "play-sound",
            "asset": "drop"
          },
          {
            "do": "return",
            "target": "self"
          }
        ]
      }
    },
    {
      "id": "cherries",
      "type": "component",
      "rect": [
        210,
        460,
        100,
        100
      ],
      "layer": 3,
      "visual": {
        "type": "image",
        "asset": "cherries"
      },
      "draggable": {
        "bounds": "scene",
        "hit": "pixels"
      },
      "on": {
        "drag-start": [
          {
            "do": "play-sound",
            "asset": "pick-up"
          }
        ],
        "drop-outside": [
          {
            "do": "play-sound",
            "asset": "drop"
          },
          {
            "do": "return",
            "target": "self"
          }
        ]
      }
    }
  ],
  "rule": {
    "kind": "place",
    "pairs": [
      {
        "components": [
          "strawberry",
          "orange",
          "pear",
          "cherries"
        ],
        "targets": [
          "basket"
        ]
      }
    ]
  },
  "on": {
    "completed": [
      {
        "do": "set-state",
        "target": "kitten",
        "state": "smile"
      },
      {
        "do": "emit-particles",
        "target": "kitten"
      },
      {
        "do": "play-sound",
        "asset": "win"
      }
    ]
  }
}