Canvas Paste Duplication Problem

0 favourites
  • 12 posts
From the Asset Store
Pixel Destruction like in "Worms" (Drawing Canvas based)
  • I am creating a kind of mini-map and I am having an issue. I am creating sectors in my mini map using canvas.

    Nested For/Next Loop:

    I spawn stars on the layout in random places.

    Create a Canvas

    Size it to layout width/height

    paste stars into canvas

    place canvas where it goes

    Destroy stars

    BUT...   Every cycle when the canvas is create it copies the previous set of pasted objects and adds the new ones to it...


    Updated CAPX-Solved

  • Ashley, (I think this should go into Bugs Now...)

    I noticed as I was playing with the CAPX above, that the primary Sprite that I deleted at startup is still being picked up by the paste into canvas event somehow. You can see it when you change the for/Next from 50 to 1 (make only one star per for-next loop) for the Sprite creating. Move the sprite to the middle of the viewable space and make it bigger. There will be 2 stars in the upper left box! Then an extra 2 compounded every box after that! Ugh!

    I am deleting the sprite in the very beginning. Is the delete not being called until the end of the event list every tick?

    (This is in addition to the Canvas Not destroying the previous pasted items)...   This may be a Canvas Issue, but I thought I would throw into your court too.

  • Just make the last empty event a sub event of the previous loop, it should work fine.

  • Danijerry, Thanks for looking at it! However, that does not work. (At least if I am hearing you right.) If I move the last event out one level it will only draw the last Row of Canvases, (and the duplication issue still persists...)

    Any other Ideas?

  • It seems to work for me.

    Ok, One step Closer, but still no cigar <img src="smileys/smiley19.gif" border="0" align="middle"> Moving it under the create star event will now produce 50 Canvases in each spot, each with 1 star... To test my theory I added Drag and Drop to the canvas and ran it again(With less repeats....) (Go to the first tile and move the tiles with the mouse to see there are multiple under the first.) You try it with your CAPX... Although it "looks good" that's not what I was going for...   

    In theory I could paste each one into the original, but for what I want to do, that wont work.

    It was worth a shot... Any Other Ideas?

  • HAHAAAAA!!!   ntm@Danijerry You actually helped me solve it! I Now Create the canvas on the Y loop and paste each star into the canvas 1 at a time then delete the star!!!!!!    YOU ROCK DUDE!   That solves all my problems.

    Thank you for helping me work through this!

    I changed the top CAPX to the fixed example... I plan on making a tutorial for Advanced Mini Maps...

  • I didn't think about the loop properly, but good that it is solved.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I was just thinking that it would cost more memory when you create and delete a sprite. Will it not be better to just update the position of a single sprite?

  • Hmmm... I might try that...

  • Indeed, it is a good practice to reuse the same object whenever possible.

  • Thanks Guys. I took your advice and noticed a significant reduction in Load time. I appreciate your advice!

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