How do I access a sprite by name?

0 favourites
  • 2 posts
From the Asset Store
Minimal Sprite Font with Stroke for Pixel Art games.
  • I am trying to make a game that has string variables which are saved as the name of a sprite, I don't know anything about javascript on how to do that, and the event sheet "System" doesn't have a way to access objects using strings from variables. Also, I need to somehow set and animation from the beginning but I don't know how to do that.

    here is the code: runtime.objects[Obj1].getFirstInstance().setAnimation("Back")

    also, I mostly use Lua as another programming language so I am not used to this.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • SPAWNING FIX

    Under system "Spawn object by name"

    spawn object (Variable name)

    So let's say your variable (let's call it "fruit") has could be one of 3 different things. Apple, banana, or grape.

    spawn object fruit

    would spawn whichever one was currently selected (grape, apple, banana whatever. Please note if the variables name doesn't match an object it just won't spawn anything)

    ANIMATING HELP

    for your animating issue I have 2 solutions.

    1. To have the animations set as the default under the actual animater

    2. Do "when object is created OR on start of layout. Set object to animation" (replace animation with your animation name and object with your object name)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)