DiegoM's Recent Forum Activity

  • Browsers block cross origin requests by default. So unless your game is hosted in the same domain as the API, any requests will be blocked. The easiest thing to do is add this header in the response the server gives for the resource.

    Access-Control-Allow-Origin: *
    

    That will let the client know that the server is allowing requests from ANY origin.

    If you want to be more specific, you can use the URL of the domain your game is hosted in.

    For example:

    Access-Control-Allow-Origin: https://my.game
    

    Using a URL instead of a * means that the server only allows request from that URL.

    developer.mozilla.org/en-US/docs/Web/HTTP/CORS

  • 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.

  • If you have any browser extensions, try disabling them one at a time and reload your project each time. Occasionally extensions can cause problems.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This is an easy to understand way of doing it.

    1) Create another array were you are going to do some temporary work.

    2) Load your real array into the temporary one using the Load action and the AsJSON expression

    3) Sort the temporary array using the Sort action. This sorts the values in ascending order.

    4) Now the first element of the temporary array is the one closest to 0, so search for the first element of the temporary array in the real array using the IndexOf action.

    That should get you the index of the lowest value in the real array.

  • I think in this case the solution was a little bit strange because the problem was not what you usually use JSON for, which is getting the values for the keys you know about.

    The plugin is setup to easily access values rather than keys.

  • Fireche

    You are running into a subtlety.

    CurrentKey

    In a For each loop, a string of the current key name. If an array is being looped, the current key is a string of the current index, e.g. "0", "1"...

    Since your data is in an array, CurrentKey will have indexes to the array. What you need to do then is load what is at that path in the json into another JSON plugin instance and then loop through that. Because the new loop in on a json object, CurrentKey will have the key names as strings.

    dropbox.com/s/3zzdt1yjk9riwwr/ReadingJSON.c3p

    The example does just that. The only thing which is rather cryptic is the path you need to give to GetAsCompactString to extract a single item from the json array.

    For this example JSON, doing JSON.GetAsCompactString("array.0") gets you the first item as a string, which you can load into another JSON object using the Parse action.

    	{
    		"array": [
    			{"foo": "1"},
    			{"bar": "2"}
    		]
    	}
    

    An extra detail I noticed while puting the example together, it seems the path you need to give to GetAsCompactString has to be absolute.

  • I am not very familiar with the inner workings of the video plugin, so I can't say for sure. It seems that setting the playback time to seek to that position and then pausing the video in the same action so the video stays there... doesn't do what I would expect.

    It might be a limitation or maybe it's just a bug that can be fixed, I'll ask Ashley about it.

  • dropbox.com/s/nltil8lv1qck1ka/RecordVideoSprite.c3p

    I changed a couple of small things, and I think it is working how you want it to.

    The first was rounding the value of PlaybackTime to two decimal places, using roundToDp. This is to make sure to save values that will be able to be found out later on. PlaybackTime is not really guaranteed to always hit the same values each time you play the video.

    The second thing was to add a check before setting the position of the dot, so that it only changes, if something was found for the recorded playback time.

    construct.net/en/make-games/manuals/construct-3/plugin-reference/array

    IndexOf always return -1 if nothing was found.

  • I see, at the moment you can only use a timeline to control the position, size and opacity of a video instance. There is still no way to preview the contents of the video in the editor, using timelines or otherwise.

    We will consider this feature for the future.

  • That feature does not exist.

    Do you mean something like the audio tracks, but for video instead?

  • Please file an issue in our tracker, following the guidelines.

    github.com/Scirra/Construct-3-bugs/issues

    In this case the most important thing would be attaching an example project demonstrating the problem. I tried doing what you described myself in a new project, and it looks like it works as expected, so I am thinking there is something particular about your project which is not obvious.

    If you can't reproduce the problem in a minimal project and don't mind sharing your project, including it in your issue is the next best thing.

    If for some reason you can't share it on our public tracker, then you can send your project to me at diegozlr@construct.net and I will take a look.

  • Sounds like something C3 could handle no problem.

    A 50 x 50 pixels image at 32 bit depth should be around 10 Kilobytes (just tried it by creating one in Windows), which isn't a lot. 500 images of 10 kilobytes would be 5000 kilobytes, which is 5 megabytes, which is still a very small amount of memory.

    The total amount of memory taken shouldn't be a problem at all, as for the rendering...

    If you create an animation with 500 different frames, C3 ends up packing everything together into as few textures as possible.

    Just tried out doing that in the editor to see what would be generated, I created an animation with 500 frames, then right clicked on the project folder in the Project bar and selected Tool > View sprite sheets. C3 ends up creating 8 textures of 2048 x 2048 which will take up 32 megabytes in RAM, which isn't a lot.

    Since all the instances will be of the same object type, it means they will all use the same textures for rendering, so no memory overhead there. All the instances will use the same 32 megabytes of loaded image memory.

    Finally, 75 instances will not be a problem at all.

DiegoM's avatar

DiegoM

Member since 24 Apr, 2015

Twitter
DiegoM has 1,400,041 followers

Trophy Case

  • 9-Year Club
  • Jupiter Mission Supports Gordon's mission to Jupiter
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

15/44
How to earn trophies

Blogs