[Solved] Picking by UID, not knowing which sprite it is

0 favourites
  • 3 posts
From the Asset Store
Minimal Sprite Font with Stroke for Pixel Art games.
  • I'm looking to pick a sprite just by UID, not by selecting the sprite first.

    Synopsis: I have a platformer which has objects in a room. As I pick up an object, I destroy it and keep track of the UID in an array. These objects differ. Eg: SpriteCoin, SpriteDiamond, SpriteDoor

    When I go to another room(layout) I am reading the array and trying to remove the entries with the UID since they were picked up before.

    Eg: Picked 3 items in the room. Item stored in Array(room#,Object.UID) as 1

    Come back to room.

    Loop through XY array

    If array(Current Room#, array.YCur) = 1

    UIDofSpriteToDestroy = array.Ycur

    Destroy Sprite UIDofSpriteToDestroy

    In searching the forums/FAQ/tutorials I see several example of picking by UID, but my understanding is that you know what sprite it is.

    Can anybody provide insight?


  • You can do all of this with the Persist behaviour, it will remember what you picked up when you go between rooms : https://www.scirra.com/manual/161/persist

    In terms of your actual logic, you can't pick the sprite plugin, only the objecttype.UID so spritecoin.UID, spritediamond.UID. What you could do is put all collectable items into a Family and use Family.IID.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • OMG you are a STAR! I hadn't come across persist, but that it exactly what it needs (per the manual write up too)

    Thank you, that is brilliant.

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