Creating new instances of objects

Get help using Construct 2

Post » Sun Dec 23, 2012 5:20 pm

I have a few related questions. I'm building a checkers-like board game. I've set the layout size to the size of the board. I've used a couple events to create the starting positions. I've given the pieces the "bound-to-layout" behavior.

A couple problems I'm having:
1) The initial piece objects are appearing on the board. These are the objects that I put onto the layout. (Question here: Why do I need to drag "initial" objects here at all? Why can't I just create them dynamically within the events code?)

I tried to simply destroy them by targeting their UID's, but it seems their UID wasn't 0 for some reason... (Pieces created with my events were being destroyed instead). So I'm not sure how/when/why these "initial" pieces are created.

I don't want to manually place the pieces on the board as their locations may differ depending on number of players and whatnot.

2) A solution I'd thought would work, and it kinda did, was to give the pieces a "destroy-outside-layout" behavior. While this worked for getting rid of the initial pieces, it had an unfortunate side-effect. WithOUT "D-O-L" behavior, players couldn't move their pieces outside of the layout, regardless of their cursor. (Because of the "bound-to-layout" behavior) However, with "D-O-L" enabled, if the player moved his cursor far enough outside of the bounds of the board while dragging a piece, the piece would be destroyed. As this wasn't acceptable, I couldn't use this "solution".

3) Last question I guess: What's the difference between "create an object" and "spawn an object"?

Posts: 11
Reputation: 347

Post » Sun Dec 23, 2012 5:28 pm

To clean up the base objects, in the On start of layout event just do a Destroy for any object you want removed before you do your dynamic placement. You'll see this trick in many of the tutorials.

Spawning allows you to place the new object in relation to another's image point. It's up to you which makes life easier.
Posts: 3,102
Reputation: 64,569

Post » Sun Dec 23, 2012 6:18 pm

Thanks. I thought I did that... but I think I did it in a new Event or something...
Posts: 11
Reputation: 347

Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, blackhornet, Eren, ochief, SimoneT, Smileh, sTARKi and 20 guests