mekonbekon's Recent Forum Activity

  • It might cause problems down the line, best to use a value like -1 for values you want to leave blank, just to keep the array tidy. You can then add a condition along the lines of "if value at array(x,y,z) ? -1 do whatever".

    Btw, you don't need to set the size of the array object, it should automatically resize to the dimensions of the json.

  • btw, I just entered the numbers 0-23 as sample data, of course you would add your song data here - make sure you change the size settings to properly reflect your array size.

  • You can make it a lot easier to enter all the data by storing it in a json file and then uploading it to an Array object using the AJAX object:

    https://www.dropbox.com/s/z6gbnqa22z7x5 ... .capx?dl=0

    Run this in debug and check the AJAX and Array objects to see how the data loads in.

    The json array file needs the following basic structure for C2 to handle it properly:

    {

    "c2array":true,

    "size":[2,3,4],

    "data":[ [ [0,1,2,3], [4,5,6,7], [8,9,10,11] ],

    [

    [12,13,14,15], [16,17,18,19 ], [20,21,22,23] ]

    ]

    }

    1) Save this text file as *.json and add it to your project by right clicking on the files icon in the Projects bar and selecting "import files".

    2) Add an array object and the AJAX object to your project.

    3) Import your json data into the array object by using the AJAX object:

    On start of layout: AJAX | Request yourArray.json (tag "yourArray")

    AJAX | On "yourArray" completed: Array | Load from JSON string AJAX.LastData

    4) All of your strings should now be in the C2 array.

    You can now work on the array however you want using conditions and actions in C2.

  • willmonteirofx

    Download the capx link again. Items were already being added to the first available slot, but I've also updated it as follows:

    Clicking on an inventory item selects it and adds it to your mouse.

    You can click again in the inventory to return an item to any slot. If there is already an item in that slot then it will swap the item.

    Click outside the inventory to add the object back to the floor.

    The text shows the currently selected item.

    Only one global variable and one instance variable! ;p

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • willmonteirofx

    How about this solution? :

    https://www.dropbox.com/s/vl30jbms1ucpf ... .capx?dl=0

    Arrow keys to move the avatar, left click on an inventory item to remove it.

    I just use one item object with the different types set to separate animations, and one inventory object with the same animations plus "none". I then lay out multiple inventory instances.

    At the start I assign each inventory slot with a number (instance variable "no"), based upon its position; I'm using the distance expression to automate this, but you can assign manually if needed.

    Each time the avatar collides with an object the code searches for the inventory instance with the lowest "no" value and an animation of "none" and matches the animation to the object.

  • Like so:

    https://www.dropbox.com/s/b3oprhlsmstee ... t.c3p?dl=0

    You need to ensure the animation speed on the card is set to zero in the sprite editor

  • If using the sine behaviour, a simple way is to set the pendulum's sine magnitude to max(self.sine.magnitude-value,0) every tick, where "value" is the rate at which you want the pendulum to slow down.

    You can then do a check to see if the magnitude is 0 and disable the sine behaviour to stop it running.

  • PreacH You're welcome

  • PreacH Would this work for you?:

    https://www.dropbox.com/s/why3eeheyjhd7 ... .capx?dl=0

    Tap any key to add a random plate.

    Left click a plate to remove it.

    Tapping a key populates calls a function that populates the array with the UIDs of all plate objects that have an animation frame of 0, then picks one at random and assigns it a random plate frame (excluding 0).

    You can scale this by adding more plate objects to the layout, no need to adjust the code.

    If you want more plates of food you can add extra frames to the animation.

  • Create one card object with 10 frames (0-9), one for each card value. Make sure the animation speed is set to zero.

    Create a global variable "score".

    Create a text object "txt_score"

    On button clicked:

    spawn card

    On card created:

    set card.animationFrame to floor(random(10)

    add card.animationFrame+1 to global variable "score"

    set txt_score text to "score".

  • No worries

  • Check out this thread:

mekonbekon's avatar

mekonbekon

Early Adopter

Member since 9 May, 2014

Twitter
mekonbekon has 13 followers

Trophy Case

  • 10-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • x2
    Popular Game One of your games has over 1,000 players
  • Famous Game One of your games has over 10,000 players
  • Coach One of your tutorials has over 1,000 readers
  • RTFM Read the fabulous manual
  • Great Comment One of your comments gets 3 upvotes
  • Email Verified

Progress

18/44
How to earn trophies