jezjones24's Recent Forum Activity

  • Yes, it is in the same event sheet, although i seem to have it working now. I think there must be some issue with saving / caching my browser.

  • This works when i call it from On Start layout, but if i put it in a function eg: populatePositions and then call that from On Start Layout, it doesn't.

    How can i find out why that is?

    It doesn't work in it's own dedicated function, but as part of the 'nextLevel' function it works.

  • Thanks for that, i was trying to do something similar but i couldn't get the syntax right... that removes the need for all the set value statements.

  • Yes, they are predefined.

    I thought about loading them via JSON but it doesn't give me the structure i need.

    (the debugger shows 10 values in the array but they are all 0)

    The output should allow me to do the following;-

    index = random number from 1-10

    array[index][0 for x position]

    array[index][1 for y position]

    then i can delete that array index so its not used again.

    [EDIT]

    I have solved my own question with the above reply.

    Set Value at (0,0) to 60

    Set Value at (0,1) to 150

    Set Value at (1,0) to 60

    Set Value at (1,1) to 265

    etc

    I just need to do that for all ten positions.

  • I am cautious about posting, because i feel it should be fairly easy to do this, but i just can't figure it out.

    I am spawning a number of sprites (between 1 and 10).

    I want them to spawn at specific locations so i am making an array (or a dictionary) to make a list of possible locations for them.

    The problem i have is how to populate that array.

    The data structure will be ;-

    (60,150),

    (60,265),

    (60,380),

    (180,120),

    (180,235),

    (180,350),

    (180,465),

    (280,150),

    (280,265),

    (280,380)

    I will then pick random items from the main array and delete the index after used.

    It is a fairground shooting gallery type game and i need to have the sprites (ducks) spawn on any of the three rows.

    Can anyone advise on how to do this... the manual goes into multidimensional arrays, but i can't see how to apply that here because the 2 numbers are always values, not keys.

    Any suggestions ? Or a better way to make a number of sprites appear but in pre-defined "allowable" places.

  • brunopalermo I need to keep the keys / indexes tied to the value since I want to create eg. 7 sprites and then press the button with an instance var of 7

    Yes array delete does work, I saw the array getting smaller.

    The reason why my results were unexpected was that the remaining values would move up the index and no longer be anywhere close to the instance var. What I was looking for was delete by value but I didn't find something to do this until i had moved to a dictionary approach.

    You are right, randomising the array and using pop would have worked quite well I think, but I ended up making it work through copying the dictionary to an array and random selection from there. Ultimately, I needed to get at the keys or indexes in a predictable way so it works for me.

    I have now completed this first (very simple) game in just 3 days since even hearing of construct 2 so although it is difficult to adapt to the approach I must take, I have made good progress...a reflection of construct 2's ease.

    For visual tools like construct, game salad etc it probably helps to never have done a code approach like unity or unreal.

    It feels like you are a little annoyed at my ignorant questions so I thank you for taking the time to guide me !

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • [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.

jezjones24's avatar

jezjones24

Member since 21 Nov, 2017

None one is following jezjones24 yet!

Trophy Case

  • 6-Year Club
  • Email Verified

Progress

7/44
How to earn trophies