nutmix's Forum Posts

  • Ok, got it working, using this (which has the X&Y order reversed):

    "{""c2array"":true,""size"":[5,68,1],""data"":[[[0],[1],[2],[0],[1],[2],[0],[1],[2],[11],[4],[5],[6],[7],[0],[1],[2],[0],[1],[2],[0],[10],[2],[3],[4],[5],[6],[2],[0],[1],[2],[3],[0],[1],[2],[0],[1],[2],[0],[1],[2],[0],[1],[2],[4],[5],[0],[1],[2],[0],[1],[2],[0],[1],[3],[0],[1],[4],[3],[2],[11],[1],[10],[3]],[[0],[1],[2],[0],[1],[2],[0],[1],[1],[11],[4],[5],[6],[7],[0],[1],[2],[0],[1],[2],[0],[10],[2],[3],[4],[5],[6],[2],[0],[1],[2],[3],[0],[1],[2],[0],[1],[2],[0],[1],[2],[0],[1],[2],[4],[5],[0],[1],[2],[0],[1],[2],[0],[1],[3],[0],[1],[4],[3],[2],[11],[1],[10],[3]],[[0],[1],[2],[0],[1],[2],[0],[1],[1],[11],[4],[5],[6],[7],[0],[1],[2],[0],[1],[2],[0],[10],[2],[3],[4],[5],[6],[2],[0],[1],[2],[3],[0],[1],[2],[0],[1],[2],[0],[1],[2],[0],[1],[2],[4],[5],[0],[1],[2],[0],[1],[2],[0],[1],[3],[0],[1],[4],[3],[2],[11],[1],[10],[3]],[[0],[1],[2],[0],[1],[2],[0],[1],[1],[11],[4],[5],[6],[7],[0],[1],[2],[0],[1],[2],[0],[10],[2],[3],[4],[5],[6],[2],[0],[1],[2],[3],[0],[1],[2],[0],[1],[2],[0],[1],[2],[0],[1],[2],[4],[5],[0],[1],[2],[0],[1],[2],[0],[1],[3],[0],[1],[4],[3],[2],[11],[1],[10],[3]],[[0],[1],[2],[0],[1],[2],[0],[1],[1],[11],[4],[5],[6],[7],[0],[1],[2],[0],[1],[2],[0],[10],[2],[3],[4],[5],[6],[2],[0],[1],[2],[3],[0],[1],[2],[0],[1],[2],[0],[1],[2],[0],[1],[2],[4],[5],[0],[1],[2],[0],[1],[2],[0],[1],[3],[0],[1],[4],[3],[2],[11],[1],[10],[3]]]}" 
    
  • I still cant figure out away to get a 2d array into an array object using the load from json string. Has anyone done this, and perhaps can supply an example? I cant really do it using "set value" as I have 300 data points.

    Any help much appreciated.

  • Not found a solution yet, but the json array structure seems to have X and Y the wrong way round.

    set reels to be 5x3x1 (i.e. x=0-4, y=0-2)

    I tried

    set value at (0,0) to 0

    set value at (1,0) to 1

    set value at (2,0) to 2

    set value at (3,0) to 3

    set value at (4,0) to 4

    set value at (0,1) to 00

    set value at (1,1) to 11

    set value at (1,2) to 12

    etc.

    But when I display "reels.AsJSON" I get some counter intuitive results something like:

    [[

    [0],[0],[0]],[[1],[11],[0]],[[2],[12],[0]...

    I was expecting:

    [[

    [0],[1],[2],[3],[4]],[[[00],[01]...

    It would appear that the Y comes first, as if the array was 3x5 not 5x3.

  • How do I set/read a 2 dimensional array?

    I always get:

    Javascript error!
    TypeError: this.arr[x][y] is undefined
    http://172.30.5.17:50000/Arr_plugin.js, line 96 (col undefined)
    
    This is either a bug in Construct 2 or a problem in a third party plugin or behavior - please report it to the developer!
    

    I'm trying to set a 2 dimensional array, then read a value from it.

    Here is the code:

    <img src="http://ohds.co.uk/c2/array-json.PNG" border="0" />

    I was expecting it to output 3, but get a JS error.

    If I dump the array as json, I get the same json as I put in, so presumably this means I used the correct (undocumented?) format.

    I also tried reels.At(2,2,0), but this generates the same error.

  • Ok, found the problem, many apologies.

    I thought I was in origin setting mode in the sprite editor, because the origin x/y dialog was visible. It turns out it was in polygon setting mode.

    This may explain why some sprites got slightly off polygons.

    My bad, sorry.

  • Until now, I have been doing my static initialisation in a "on start of layout".

    However, on mobile, the user can switch between portrait and landscape layouts. Each time they switch back to portrait, I am guessing that "On start of layout" is run (although I dont know this for sure).

    The question is, how to only run something once ever, no matter how many times the layout is swapped?

    E.g. could I do:

    Global DoneInit = 0
    System DoneInit = 0 -> System set DoneInit to 1
                        -> (do static initialisation of stuff)
    

                  

    And this only ever get called once, or do global vars also get re-initialised when you switch layouts?

  • This fails in both versions.

    I have an animation which consists of 9 square frames of the same size, all with the origin (aka hotspot) set to 0,0.

    Now I want to add additional frames (also square with the same size).

    I add the frame in the frame editor, then "open" the image in the sprite editor, and by default the origin is already set to 0,0 - great!

    Except that when the new frame is displayed, it is using an origin which is the center of the image (not 0,0). Now if I try and change any origin (e.g. to 1,1), when I close and open the animation/sprite editor, it goes back to 0,0.

    It seems that behind the scenes the new frame is using the center as the origin, but is displaying 0,0 in the sprite editor.

    This is pretty serious - I've come to a bit of a halt.

    I cant delete the sprite and start again, as it will delete the hundreds of events which are using that sprite.

    This should be easy to reproduce (just create a sprite with a few frames, set the origin to 0,0, save the project, close C2, then open the project, add a new frame, then "open" the file containing the image, verify the origin is 0,0, then display the image in the game - it should appear offset by -0.5*width and -0.5*height

    I created the original frames in an earlier version of C2 (R95?)

    Let me know if you need a capx.

    Here is a snip of the animation in the project file:

               <frame duration="1" hotspotX="0" hotspotY="0" />
               <frame duration="1" hotspotX="0" hotspotY="0" />
               <frame duration="1" hotspotX="0" hotspotY="0" />
               <frame duration="1" hotspotX="0" hotspotY="0">
               <collision-poly>
                       <point x="0" y="0" />
                       <point x="0.991803" y="0.00819672" />
                       <point x="0.991803" y="0.991803" />
                       <point x="0" y="1" />
               </collision-poly>
               </frame>
               <frame duration="1" hotspotX="0.5" hotspotY="0.5" />
    

    Note the last frame has the wrong hotspot. However, in the sprite editor, its coming up as 0,0

    Also, why would some of the frames have a collision polly, and some not?

    Would it make the game faster if I deleted the collision plolys (which I dont need in this case)?

  • R105 fixes this issue on iphone 4 and iphone 3 and ipad

    Also, the removal of address bar works.

    Result!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Another option is to use crop fullscreen mode. Then your canvas is the maximum size possible, you have entire browser window to play with. You can make a massive background (e.g. from a single pixel tile), then put your game anywhere on it by moving your objects, incl. level backgrounds around. You can put sprites and text objects into two different families, then use bullet behavior on them to move them, or pin all your objects to a background and move that. you can also set the layer scale to make the game bigger or smaller without having to do anything (this is basically letterbox scaled mode but with the ability to set your own background colour)

  • Ashley, you are fast!

    Will this also fix the similar issue with going from portrait to landscape on the slower iphone 3?

    Thanks!

  • I've had this problem for some time, so decided to create a 2 event capx to demonstrate it as the game has failed the customers QA so im not getting paid :(

    If you go from landscape to portrait and back, it correctly flips between the landscape screen and the portrait layout.

    But if you are in landscape mode, and rotate the mobile (iphone 4) by 180 degrees, the screen goes black. As a secondary problem, in my actual game, it will not accept any input or events at this point either.

    Here is the live exported project:

    http://www.ohds.co.uk/c2/landscape_going_black_fail/

    It doesn't work in iphone 4 (ios 5) nor ipad 3, the only two platforms I have to target.

    Here is the capx:

    https://www.dropbox.com/s/f9enc1v26d4mg3t/landscape_going_black_fail.capx

    Note: there is a slight modification to the index.html to support iphone4 removing the addrss bar. But this code is not run for the ipad, so I dont think its that (and if it was, I would still need to find a solution as removing the address bar is an absolute requirement for any casino type game on the iphone, unfortunately).

    Please note:

    1) using phonegap or similar is not an option, these games have to run in HTML5 in a mobile browser.

    2) I have to use crop mode to support various screen sizes without black bars.

    In addition, on the iphone3, sometimes this black screen of death happens when you just go from portrait to landscape, or even from landscape to portrait, then it often stays black (i.e. going back to portrait still shows the broken black screen). Interestingly, this exactly what happens sometimes in my real game. So it seems to be an issue where if the phone is slow, or the app is complex and slow, the switch between portrait and landscape layouts fails frequently but not always.

    Thanks for any help, it is much appreciated.

  • Thanks Ashley. Is the layouts event sheet run in its entirety from top to bottom per tick? If so, then as you say I could be "calling" the other event sheet twice.

    I am testing out the function plugin, but Id rather be able to throw and catch my own event!

  • Different mobile phones run different FPS. Has anyone done anything in JS to detect the relative speed of the device? I have seem some JS which just loops for a few MS to see if its an iphone 3 (very slow)or iphone 4 for example.

    Obviously I can use the System-> Is on mobile device, but this doesnt tell me if if Im running say ipad3 (which is very fast) or an ipad 1 (which I need to no do some animations etc.)

    Any ideas?

    I could just do a loop a 100 times and see how long it took, but you never know what the phone is currently doing.

    I use the browser string to see if its an iphone or ipad at least, but you cant do much more than that.

  • I know what it might be - the text object which killed performance had an anchor behavior. I was overriding this to make it centered (anchors cant do this). I expect this was the problem.

  • If I create an event sheet called say "myfunction", and in it have one event:

    System 0 = 0 -> bunch of actions

    Then import the sheet in several different events in the main event sheet, will this work like a function call?

    It seems to.

    I.e. can I call the myfunction several times (not just once) from the main sheet.