How do I make a number list

0 favourites
  • 5 posts
From the Asset Store
Build Social Apps, Chats and Advanced Lists using Firebase Realtime-Database
  • Ok so basically I'm trying to make a kind of DNA for sprites where 1=up, 2=left etc... Is there anyway I could make a list or something similar and go through it one at a time to control which was the sprite moves?

    Example: 1,3,1,2,4,3,2,1

    Sprite would move: Up, down, up, left, right, down, left, up

    How could I do something like that? Or is it not possible with construct 2?

  • my first thought is to use tokenat

    from the manual -

    tokenat(src, index, separator)

    Return the Nth token from src, splitting the string by separator. For example, tokenat("apples|oranges|bananas", 1, "|") returns oranges.

    you could also look at arrays.

    If you have not had a better answer when I check later I will try to put a capx together for you

  • Although you have already had a capx from mrcgkh I will post this as I have spent a bit of time on it and think it is worth pursuing...

    This i what i came up with - not quite what you asked for <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    instead of "l,r,u,d" or "1,2,3,4" I went for x,y#x,y ie the change in x and the change in y which will allow for diagonal movement so to move left 3 times left (then back) it would look like "-1,0#-1,0#-1,0#1,0#1,0#1,0" the number represents the number of pixels per step . so "-10,10 would move the sprite - 10 pixels in x and plus 10 pixels in y.

    I included a timer so the same "movement string" can run at different speeds.

    https://db.tt/AJB1ZmkY

    let us know how you get on ?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you both, I'll try them tomorrow and see how they work I appreciate how quickly you replied and put something together

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