jezjones24's Forum Posts

  • [SOLVED]

    So the short answer to this is use Dictionary, not an array. Then cast your int to a str and delete the key and value from the dictionary.

    Using an Array means that the index will be deleted but the shuffling of the rest of the contents to new index positions detaches them from being found by any link to their index, this increases the more indexes you delete.

    eg. array index 9 has a value of 10 at the start of the game, but when a lower key is deleted the index of 10 shifts to 8 and then 7 etc as more indexes are removed. So when you have 10 buttons, each to delete that value from the array, you cannot rely on an instance variable on the button (eg 10) being used to find index of 10 in the array, except for the first delete.

    To then still find a random item, you need to copy the dictionary to an array after each deletion, then use the random(array.width) approach to select a random one (thanks to this for that end part->)

    It seems obvious now and was only made possible by using the debugger, for some reason i didn't think this was available in the free version - it is.

    I hope this helps someone and shows that I really do trawl through the forums, manual and examples before posting seemingly obvious questions on here.

    Thanks

  • Ok, so i have been going through this every which way, so if i there is a source of info i should be looking at, please direct.

    Basically, I think that array delete removes the index but then effectively just pops the value off the back.

    I am using an array of numbers to generate a random number that will not be repeated.

    I populate my array (numbersShown) with 1 to 10 at x positions 0 to 9.

    Each time i want a number i call numbersShown.At(floor(random(numbersShown.Width)))

    This works well.

    I am displaying that number of sprites.

    The user clicks on a number button that has an instance variable for a number (1 to 10).

    numbersShown - Delete index int(Button.clickedValue -1) from X axis.

    The length of the array is getting shorter, but I see repeat values when i call numbersShown.At(floor(random(numbersShown.Width))) as though the last value on the array is dissappearing, not the value at the index.

    Alternatively, the shorter array is not picked up until the next tick but that is not something i am sure about.

    Any suggestions?

    Thanks,

  • Yes, i agree with both of you.

    While i may seem like i am asking basic questions here, the event sheet of my first app shows that i have managed to figure out quite a decent amount.

    The problem is how to think about things, mainly about how to stop things happening since its all being executed in one tick or to speak in a Unity way, within the update function where there is only one function that is executed on each frame update. Others are triggered with events that don' t have to be "every-tick-proof".

    It is one of the bugs/features of visual coding, even Scratch makes you think differently.

    I think i am getting there, thanks for both of your help!

  • Thanks for your replies.

    brunopalermo I really am, looking at the manual before posting here.

    My problem is that i am thinking about it the way you would normal code and the manual doesn't really explain that you need to chain multiple events like this.

  • Still having trouble with conditions.

    I am trying to compare the instance variable of a button being clicked with the variable for the number of animals on screen.

    I have buttons 1 to 10 and i would like to show Win/Lose depending which was pressed.

    I am using button->compare instance variable, but it seems to be executed every tick, not on the click of the button.

    I tried to put it in the button->onclick event but there is no option at that stage to compare the variables.

    I also tried making a function and giving it an event condition for if the passed parameter of the instance variable was correct it would execute. That worked, but it gives me no way to deal with a wrong value being passed.

    Again, i am looking for IF & Else here but the logic escapes me.

    Any suggestions?

  • newt

    Thank you very much, i was able to implement that without any great problems but I dont think we need the canspawn variable. Once the animalCount is no longer < howMany, the spawning stops.

    I appreciate all the help here.

    I did look at the tutorials and manual, but I could not find anything that explained this.

    Thanks

    Oh and Magistross - I can't install anything but the stable version, i am using Construct by order of a client - hence the lack of experience. If i get enough work from them then i will be buying the liscence but right now this first task is paying only the same as the cost of the license itself.

  • Magistross - I get a message about release 247 vs my release 244.

    I installed construct 2 yesterday, are you on a different release?

  • Try Construct 3

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

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

    When the game starts a couple of global variables are set.

    The quantity of animals to spawn - between 1 and 10. (howMany)

    A variable that selects which animal is used based on an array. (whichAnimal)

    This quantity of animals need to be spawned consequetively, not all at once. Ideally, once every 0.5 seconds until they are all there.

    I have a spawn function that creates the right animal in a random location, right now it is repeated for the quantity.

    It is triggered on "on loader complete" because i cannot find another trigger to get it to run.

    The idea is that a random number of animal sprites are created at the start of the game. They can be of a number of different types. Right now they all appear suddenly, I would like to have them appear individually one after another. This is a counting game for children.

    How can i set up the calls to the spawn function to take place in sequence.

    For example

    for(howMany){

    spawnAnimal();

    wait(0.5 seconds)

    }

    If i do anythying like this there is no limit to the spawning. The loop does not end.

    Only by calling "On loader layout complete" -> Function Call spawnAnimal()" do i get the limit on the amount spawned. It calls it once. Then i use Repeat (howMany) to repeat the call for the number of animals i want.

    Also if i add any kind of wait to the function or the call, it is simply ignored.

    How can i add a condition somewhere to do this with a time delay until a condition is met or for each instance until there are "howMany" on screen.

  • zenox98 - I have gone through the manual and several templates, hence the question.

    It's a little dissappointing that rather than point me to a specific template or area of the manual you just blast me for being wildly misinformed.

    The event system information is what leads me to state that the event sheet is executed each tick.

    Please, if I am so wildy mis-informed direct me to somewhere i can read more.

  • Ok, i am new to Construct, but i am finding it a little crippled.

    The event sheet is run every tick right? So that means it is very difficult to set game level actions.

    I want to spawn my animals (not enemies) when the game loads. There will be between 1 and 10 of them. I want to spawn them at 1 second intervals. The only way i can get them to spawn is with "on end of layout" or "on start of layout." - I have no idea why that is.

    I have a spawn function, this is fine. I call it with Repeat using a variable i set.

    I would like them to appear one by one with a delay of 1 second. This is not possible with the wait function as the function can only be called at the start of the game. I cannot use an IF statement to see how many have been spawned and use that as a limit.

    Please can someone tell me how you control spawning within fixed amounts instead of generating them all at once on load.

    The event sheet is called 1 time per tick but also there are no IF statements so standard approaches to coding seem to be useless here.