How do I create a symmetry control of an object?

0 favourites
  • 4 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hi to all teachers...

    Can someone tell me how can I create a symmetry control of an object??

    A screen size divided by 2 and press left area, it moves left; right area, it moves right.

    I'd put the "2x button" atm, but prefer if it can make it into symmetry control.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • First of all, you need to have an instance variable (let's call it "whichSide") to keep track of which side of the sprite would take. In one of the two sprites, set this variable to be non-zero. Under your control input, you will have "For Each" event for addressing each sprite individually, and check each sprite's whichSide variable, and proceed with the movement accordingly.

    Here is an example:

    Pressing left will move sprite that has whichSide value of 0 to the left, and the other with non-zero value to the right. Pressing right will be the opposite of the above.

  • hi keroberos,

    thanks for your pro answer. Really, that's way too pro to me.. your event syntax need has to identify where the sprite and that should be right way

    however, I just want a bit more simple, 50% 50%.. half area move left, half area move right.

    I'd triedmake the button opacity become 0 so it can be press invisibly but fail....any other simple method to solve this?

    :p

  • How about use "Compare X" in "for each" instead of comparing the variable "whichSide"?

    For example,

    Press Left

    • For each,
    • - if x < 400 : Sprite.x = Sprite.x -120
    • - else : Sprite.x = Sprite.x +120

    You have to place something like Solid objects in the middle to prevent the sprite to go to the other side. (otherwise, with this method, you might have a bug that both sprites move together on one side.

    Logically, it is acceptable...

    OR actually, a simpler method would be:

    create 2 sprites with exactly same animation, etc., but name them differently, maybe player_LeftSide and player_rightSide.

    Now, in your events:

    Press Left:

    • player_LeftSide.x = player_LeftSide.x - 100*dt
    • player_RightSide.x = player_RightSide.x + 100*dt

    Press Right:

    • player_LeftSide.x = player_LeftSide.x + 100*dt
    • player_RightSide.x = player_RightSide.x - 100*dt

    This will allow you to make do without using "For Each". However, this event design may make you doing things for the player twice.

    Is this ok for you?

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