Appending string according to player position

0 favourites
  • 4 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • I have a player object moving upwards. On the level layout there are letter objects scattered around, ie.: AABBCD. Each is placed higher then the other. So A is at the bottom and the D is in the top.

    Every tick I want to check what 4 letters will be the next letters that player can collect - what 4 next letters are now higher then the player object. These 4 letters I want to print. I implemented it already, but somehow it's not working for last 3 letters or less. It should work like this: if less then 4 letters are ahead of the player, display just 3 letters, etc. In my implementation if there is just one letter ahead (ie.: E) it creates string: EEEE, and not: E.

    I don't know how to make it work. Here is my .capx: sendspace.com/file/4y3wcj

    Thanks!

  • Here try this:

    next4Treasures.capx

  • Thanks ramones :) It's working great. I'm just wondering why there should be the first line? Why are you setting Text to "" everytime one of the treasures gets behind the player?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I just set the text to blank and then append the 4 letters in the loop. If you didn't set the text to "" first you'd be continuously adding letters onto the end of the string.

    You could add the the letters to a variable and then set the text equal to that variable if you wanted to do it that way.

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