Visual leaderboard / sprites positions ?

1 favourites
  • 15 posts
From the Asset Store
This music pack covers differents situations for visual novels, anime games and many more!
  • Hi everyone, I need some advice :)

    I´m working on a visual leaderboard that loads names and scores from a MySql database. Everything is working fine when loading a classic leaderboard.

    I am trying to make it more visual, let´s say a car race with each user being represented by a car.

    So far things are "ok", but, I´d like to place the name and score with each car, but since array data is loaded based on each instance variable, I´m having a bit of trouble with this.

    Also , as a second thing, since scores are loaded from top to bottom into the array, I always get the same visual shape (looking like: "/"), and I would like each car to keep it´s Y position. I´ve been pulling my hair with this one

    Is that possible at this point? Am I approaching this with from a good point of view? Should I try to get the cars/position from the mysql database?

    And as a third thing: Cars right now set their x position based on scores/pixels. How could I set a % based on the overall scores?

    Any opinion/help is super welcome, thanks!

    This is exported right now in: badablu.com/desarrollo/visual_leaderboards_v1

    And the c3p file is in:

    badablu.com/desarrollo/visual_leaderboards_v1/visualLeaderboards.c3p

  • I hope I understood your question correctly, here is a demo:

    dropbox.com/s/90po3uh49sekbx1/VisualLeaderboard_dop2000.c3p

  • dop2000 Thanks so much for your kind answer, I'm trying to figure it out yet, I'll try to give a proper answer soon :)

    I see you read the names/scores as json locally I can imagine this can be done remotely too, however I'm trying now to understand how to format my mysql data into json now but I am still lost... Not sure what path to choose, since my knowledge on any path is pretty low.

    I have tried to format mysql data as json using php, yet I havn't been able to make it work... yet :P

    Do you have any other tips or ideas on how should I see this?

    thanks so much again!

  • dop2000

    This is the php Im trying to use to format mysql as json

  • Have you tried requesting your data from your database as it exists now and then arrange it in the client as you need it? It looks like the example is doing pretty much what you described, all you need to do now is fill in the array with your own data.

    Instead of using the Load action to fill up the array from a file, you can use the Set XY action of an array to tell in which coordinates each value should go.

    To follow the format of the example dop2000 gave, you would use 3 actions to set all the values for each player.

    Set XY (0, 0, 1900)

    Set XY (0, 1, "Sam")

    Set XY (0, 2, 1)

    Those actions will set all the values in the first column...

    Set XY (1, 0, 120)

    Set XY (1, 1, "Pete")

    Set XY (1, 2, 2)

    Those actions will set all the values in the second column... and so on.

    Once the array has been filled up, the rest of the example should work just fine.

  • DiegoM Thank you very much for your answer, I´ll try to see how it goes using this method and will post results as I solve this, thanks! :) At first it seems confusing to me, but I{m sure that with time and patience I´ll have it running eventually lol

    And by the way, since we are here, I want to thank you and dop2000 for all the help you guys give here, as a low knowledge user, I usually search this forum for almost everything I do finding already answered questions, and your names are always present, so THANK YOU! Without even you knowing it, you have already answered A LOT of my questions :)

  • 11 days have passed..... and I´m still not sure what am I doing.

    I got this to "work" with the suggestions made by DiegoM and dop2000, thank you so much!

    Now, seeing that Dop2000´s suggestions are on the json side, I started trying to understand dozens of posts about json and arrays... I can have my data sent it this way:

    {

    "rank": 11,

    "score": 14.0,

    "userId": 46.0,

    "userName": "Varsovia",

    },

    {

    "rank": 12,

    "score": 12.0,

    "userId": 43.0,

    "userName": "Istambul",

    },

    How can I put this into an array? is it possible to separate each score, userId, username, etc?

    Thanks so much,.

  • Hi, I´m still fighting this visual leaderboard thingy.

    Worked on dop2000 example and also on this postbut havn´t had much luck with this json file (I can make it work using mysql, or json with identifiers before the { )

    If I don´t have one, I don´t know how to gather each block information independently, any ideas that can help me here?

    Right now, every sprite gets the data of the last json block

    Thanks so much in advance :)

    This is my file today

  • You should use either "For each sprite" loop, or "JSON For each entry" loop, not both!

    If you are using "JSON For each entry", then inside this loop pick one instance of the sprite.

    For example, you can manually set Rank values for all sprites. And then pick the sprite for each entry by rank:

    JSON For each entry
    Sprite compare instance variable Rank=JSON.get(".rank")
    ... Sprite set UserName etc.
    
  • Thanks again for trying to help me, dop2000

    You mean like this?

  • Not exactly..

    Since you have an array in JSON, you can pick by comparing sprite ID with the index in JSON array. And add Description and Sprite in a container. Here is the fixed file.

    dropbox.com/s/v5m52m7m99c5vhg/borrador%20load%20json2.c3p

  • Thank you very much dop2000 for all your help, I trouly appreciate it :)

    You make it look so easy, I pulled my hair with this one for weeks.

    I will upload the file when I finish, in case someone else finds it useful. THANKS!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hello everyone. Hate to bring this up again, but I´m still having some issues relatad to this project, and since it´s in the same category I thought that having it in the same post might be useful if someone else is facing the same problems I had.

    With the help of dop2000,DiegoM I did get almost everything running. THANKS SO MUCH!

    However, now I have the need of placing: for each score, a "graphic/visual/etc" for each score, but I´n not sure how I could pair sprite frame images with this that was loaded with ajax into an array: tokenat(AJAX.LastData,ArrayPlayers.CurX,"|")

    Is there any tip or pointers you can give me on this one too?

    I´d like somtehing like:

    for each graphic(at), set frame score(at) is showing

    This is where I get lost

    I´d need to do something like this:

    If player(at)value is less than 100 , show "bronze icon frame"

    If player(at)value is greater than 100, show "silver icon frame"

    Is player (at) value is greater than 300, show "gold icon frame"

    Is that possible? Am I looking this the right way?

    Thanks so much in advance

  • This is where I get lost

    I´d need to do something like this:

    If player(at)value is less than 100 , show "bronze icon frame"

    If player(at)value is greater than 100, show "silver icon frame"

    Is player (at) value is greater than 300, show "gold icon frame"

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