Canvas Paste Duplication Problem

Discussion and feedback on Construct 2

Post » Thu Apr 05, 2012 7:19 pm

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...

WHAT AM I DOING WRONG???   



Updated CAPX-Solved http://www.box.com/s/578b7dfdb3332fa7408eZetar2012-04-06 01:49:07
B
192
S
6
G
7
Posts: 213
Reputation: 10,178

Post » Thu Apr 05, 2012 10:48 pm

@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.Zetar2012-04-05 22:50:39
B
192
S
6
G
7
Posts: 213
Reputation: 10,178

Post » Thu Apr 05, 2012 11:06 pm

Just make the last empty event a sub event of the previous loop, it should work fine.
B
28
S
9
G
6
Posts: 30
Reputation: 6,609

Post » Thu Apr 05, 2012 11:18 pm

@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?
B
192
S
6
G
7
Posts: 213
Reputation: 10,178

Post » Thu Apr 05, 2012 11:47 pm

B
28
S
9
G
6
Posts: 30
Reputation: 6,609

Post » Fri Apr 06, 2012 1:31 am

[QUOTE=Danijerry] It seems to work for me.

http://dl.dropbox.com/u/28195143/c2_share/CanvasPasteProblem_fix.capx[/QUOTE]

Ok, One step Closer, but still no cigar 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?

Zetar2012-04-06 01:34:26
B
192
S
6
G
7
Posts: 213
Reputation: 10,178

Post » Fri Apr 06, 2012 1:45 am

HAHAAAAA!!!   @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...
Zetar2012-04-06 01:50:35
B
192
S
6
G
7
Posts: 213
Reputation: 10,178

Post » Fri Apr 06, 2012 2:00 am

I didn't think about the loop properly, but good that it is solved.
B
28
S
9
G
6
Posts: 30
Reputation: 6,609

Post » Fri Apr 06, 2012 2:50 am

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?
B
28
S
9
G
6
Posts: 30
Reputation: 6,609

Post » Fri Apr 06, 2012 4:33 am

Hmmm... I might try that...
B
192
S
6
G
7
Posts: 213
Reputation: 10,178

Next

Return to Construct 2 General

Who is online

Users browsing this forum: spacedoubt, Unconnected and 1 guest