What's wrong in my code

Not favoritedFavorited Favorited 0 favourites
  • 9 posts
From the Asset Store
5 levels with simple coding Source-code (.c3p) + HTML5 Exported
  • Another Question

    please look at my code in the image and tell me what's wrong i did here

    I am trying to slide data of array

  • i noticed that above code is working only for y0 and it doesn't working for y1,y2,y3 looks like LoopIndex("y") doesn't working

  • In your "NewPosition" function, the first action set a value at (x,y) to a value located at (x+1), and indeed no mention of y.

    Your second Array.at is not a valid location and will likely return 0.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Kyatric but why ?

    Your second Array.at is not a valid location and will likely return 0.

  • Because in a 2D array, you are referring to a 1D position.

    Your action should be:

    Set value at (Loopindex("x"), Loopindex("y")) to Array.at(Loopindex("x")+1, Loopindex("y"))

  • OMG! thank you so much

    its working now

  • Also:

    1) In your new number function you're using Array Cur Value condition incorrectly - it only works in conjunction an Array: for each XYZ element condition.

    2) The repeat may pick the same co-ordinates twice so you may only get one number in the array.

    3) Using int(0,3) won't pick 3 and may put a number on X=0 so when you slide it will disappear off the array.

    Here's an example that I think gets closer to what you're after:

    dropbox.com/s/yu4sgvidmpocp32/slideArray.c3p

    Note that this only works if you're sliding to the left - if you change the slideX value to positive then there's a chance you can overwrite values as you slide, due to the order in which the For Each XYZ element condition proceeds.

  • Another Question

    i have array 4x4x1 and creating data at random position and sliding that to up, down, left and right

    I have created Sprite "grid" 4x4 on layout and another sprite "box" which i want to create and slide as data in array creates and slide.

    How do i do that moving data inside array also move "box" to same direction.

    i am stuck on how to apply array moves into "box" sprite.

    please help.

  • Here's an example that allows you to move blocks around a grid without overlap - if you want the blocks to combine "Threes" style then you can modify the array value conditions in event 14.

    dropbox.com/s/yu4sgvidmpocp32/slideArray.c3p

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