How do I create a symmetry control of an object?

Get help using Construct 2

Post » Thu Apr 24, 2014 6:32 am

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.
B
8
S
1
G
1
Posts: 26
Reputation: 638

Post » Thu Apr 24, 2014 1:49 pm

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:

Image

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.
I got a game that you multiply, breath fire with two heads and brawl foes to oblivion with your clones: http://www.newgrounds.com/portal/view/660664 (use Chrome on Windows for best performance)

My sites:
http://twinblazar.deviantart.com
http://twinblazar.newgrounds.com
https://twitter.com/twinblazar
http://www.pixiv.net/member.php?id=15072448
B
30
S
11
G
11
Posts: 411
Reputation: 8,469

Post » Thu Apr 24, 2014 3:13 pm

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
B
8
S
1
G
1
Posts: 26
Reputation: 638

Post » Thu Apr 24, 2014 3:37 pm

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?
I got a game that you multiply, breath fire with two heads and brawl foes to oblivion with your clones: http://www.newgrounds.com/portal/view/660664 (use Chrome on Windows for best performance)

My sites:
http://twinblazar.deviantart.com
http://twinblazar.newgrounds.com
https://twitter.com/twinblazar
http://www.pixiv.net/member.php?id=15072448
B
30
S
11
G
11
Posts: 411
Reputation: 8,469


Return to How do I....?

Who is online

Users browsing this forum: Maydie and 38 guests