0 Favourites

How to spawn an object, but always on different imagepoint

  • Hello

    Its hard for me to explain my issue so I ve made caps. file..

    [attachment=0:2ckj4ge3][/attachment:2ckj4ge3]

    So when Player destroys that crate, I want to create that crate again but on platform- imagepoint 2. Then when crate is taken again -> create it on platform-imagepoint 3 and then, repeat that process, so it appears again on platform-imagepoint 1.

  • For sure it is not the best way, but it works(if I understood what you want) and was what I thought in the moment.

    [attachment=0:3d1wi7fq][/attachment:3d1wi7fq]

  • yes yes you understand what I want

    Thanks for help

  • ...or you can use Spawn object.. no need to type every time X..Y

  • Or just stop making games.

  • Setting the position wreaks less havoc on the cpu. The more objects you create throughout the life of the program, the more negative the more the cpu is bogged down. You obviously won't see a difference with only one object, but when you have more than 20 spawning and being destroyed, over and over again, you can see a major difference.

    If you're looking to move it to another place on screen that's visible, you can always set it to invisible on collision, move the sprite, then when it's time, set it to visible.

  • Thanks for your replies guys I appreciate that

  • Or just stop making games.

    hh, what ?

  • Tekniko received a PM asking him to be more considerate when posting. Such reactions makes no sense and are really not constructive.

  • iwontnamemyself could you specify this a little further?

    [quote:1d8tj08k]Setting the position wreaks less havoc on the cpu. The more objects you create throughout the life of the program, the more negative the more the cpu is bogged down. You obviously won't see a difference with only one object, but when you have more than 20 spawning and being destroyed, over and over again, you can see a major difference.

    do you mean the progreamm will run slower and slower over time? i made a top down shooter spawning and destroying the same anemys over and over again, so far i didnt noticed an impact...

    regards

    joschi

  • j0schi - The more objects you create and spawn, the more the cpu is used. Take an infinite runner game for example, particularly temple run. There is an infinite board and there are a serious of 10 or so coins to collect in spurts the entire way. If you were to create the random board (which is needed in that type of game) and create new coins after each one is collected (my ex-boyfriend's daughter hit over a million coins collected and she's only 8) that would use well over 50% of the cpu. At the very least and that's far more taxing than any program should be.

    But...if you just move the same 10 coins or 20 coins as they are being collected, the player will never notice the move and it'll save the fps and cpu.

    Kyatric offers this link in ddaan9 's post about spawning vs. visibility

    https://www.scirra.com/blog/112/remember-not-to-waste-your-memory

    Then again...if you're only creating a couple objects and you never destroy them , your cpu and fps rate probably won't even budge.

  • iwontnamemyself thanks for the clarification. what i thought was that when a object is destoyd (bullet hit enemy OR enemy is not in layout -> enemy destroy ) would to the trick and memory / CPU is free for other objects to spawn... my game spawns far more than 8000 objects and they get destroyed after leaving the layout or when they get hit by a bullet... and i ran in no troubles.

    when i didnt destroy the bullets outside of the layout however the load bagan to rise, which is normal.

    so i will run another test and spawn 8000 objects and will look at the memory/cpu if it will have any impact.

    regards

    joschi

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • j0schi - Do you have over 8000 objects on the screen at one time, or are you spawning 8000 objects over the course of the game?

    May I suggest, if it's possible, to turn the visibility off and add a visibility check before anything is suppose to interact with them. That way, all your code only acts when they are visible, so you're not having to create and destroy a ton of objects. Then you can reposition and make them visible again when you need them.

  • iwontnamemyself i am spawning over 8000 objects over the course of the game... didnt noticed any impact

    regards

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