How do I create an object in random positions?

  • Does Arrays work in this situation?

    What would you want the array to do?

    Please explain what is wrong with the solution korbaach gave, so it is more clear to us what you want..

    Sharing your capx and/or your events might even make it clearer..

  • Does Arrays work in this situation?

    Arrays work in any|every situation <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">

    The question is ... they are really necessary..

    Array capx> http://s000.tinyupload.com/index.php?fi ... 3327052285

  • LittleStain After working on couple of minutes, I understood that Choose attribute is working and Arrays are not required.

    Thanx alot man

    Also , Thanq for ur time.

  • Did you find out why your animation wasn't working?

  • Now its working. But I have one more problem that is, sometimes the object is appearing in the same position twice. For example, the object is appearing on position (10, 10) again it is appearing in the same position with just a small time difference, that shouldn't happen. Simply, It is overlapping on itself. I also used 'Object is not overlapping' expression but it isn't working. Do you have any solution?

  • well, random is random so duplicates may happen.

    In your case a 1 in 16 chance.

    korbaach knows a better way I am sure, (please let us know Korbaach )

    but

    one way is

    I like using sprites as it is more visual for me...

    .

    be sure to change the count to however many sprite2 you have on your layout

    and

    remember even in this example above, when the count resets to zero, there is a chance (1 in 16 your game) it may reset to the same sprite.

  • ...not so elegant..and not so random solution..

    ..but simple..no arrays,loops,functions...

  • or

    if you prefer the sprite method.

    Here is a way to NEVER repeat.

    you need to have

    2 instance variables on the SetSprite.

    One for Overlap and

    another for LastOne

    and the wait time to change the LastOne from 1 to 0 needs to be a touch longer than whatever the Every X seconds count

  • Lot of learning, Thanq for both of u korbaach

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • korbaach your solution is working only on X axis, I can see overlapping on Y axis. I tired to put all the combinations of X&Y but it's becoming a lengthier code, instead do you have any other way of solving it?

  • Why not consider using the sprite method above?

    And, if say, you want to add ( or subtract) the number of enemy positions during the game,

    it is probably easier to do that with the sprite method and keep the game in

    one layout/event sheet

  • I'll surely try that now. Tnx

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