Creating new instances of objects

0 favourites
  • 3 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • 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"?

    Thanks!

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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks. I thought I did that... but I think I did it in a new Event or something...

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