Quick question on UIDs

Not favoritedFavorited Favorited 0 favourites
  • 2 posts
From the Asset Store
Logo Quiz with 150 prepared logos and answers, automatic question and answer mixing
  • hi,

    At the moment i have 5 object sprites displayed on screen in a row and have stored their relevant UIDs and position in an array.

    I would like to wrap or loop the arrays around on a key press and then update the display so the objects on screen match the values in the array!

    I can get the arrays wrapping around fine by key presses but unsure how i can then get the values to update what is displayed on screen and where!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Well with your current setup after you move things around in your array, you’d want to loop over the array, pick the objects by uid and update the position from the array.

    If that doesn’t make sense then maybe you want to move and wrap those objects around in another way?

    One possible way works if those five instances are the only instances of that object type and you places them in the editor from left to right.

    You’d then add an instance variable “oldx” to the object type and you’d swap the positions of all the instances to the one on the right (or rightmost with leftmost) with:

    On key pressed
    — sprite: set oldx to self.x
    — sprite: set x to sprite(self.iid+1).oldx

    To move left instead you’d replace the +1 with -1.

    Or you could do something else entirely.

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