Todays problem.. How can I create an L-shaped object that can be moved by touch?

StormyStudioStormyStudio United KingdomMember Posts: 3,989
edited November -1 in Working with GS (Mac)
Ok so todays task.. How can I create an L-shaped object that can be moved by touch?

I know I need to link positions of two actors, a long rectangle one and a square one. But I also want to be able to move the object with touch, and it also be affected by gravity and if it rotate for it to stay together. Sort of like an 'L' shaped piece in Tetris....(I'm not making tetris but you get the idea).

Any ideas or experience doing this would be brilliant.

Comments

  • harrioharrio Member Posts: 234
    what's cookin,

    i think you will want to constrain the positionx/y of the 'square' to an offset of the positionx/y of the 'rectangle'. that way, you can move them and they will remain together because of the constraint.

    ex; constrain position x of 'game.square x' to position x+30 of 'game.rect x'
    constrain position y of 'game.square y' to position y-10 of 'game.rect y'

    i think this will work, although someone else may have a better solution.

    noodles...
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    @t-shirt booth: Would probably only need a maximum of 3 at any one time per level, If it is a real drain I guess I would have to leave them, but it would add some more varied gameplay to the game, which is essentially a balancing game with a twist. From what I understand pixel collision is never gonna happen with the current physics engine...But linking is possible they just have'nt integrated it into to GS yet.

    Harrio, thanks for the reply, I thought it would be something along those lines, I'm not on GS right now so cannot test it, but would that work when either actor is touched and moved, or would it only work if the one actor was touched. I guess it would need the constraint on both objects onto each other. As well as touch settings on both. Also would this allow for rotation, or would the position go wrong....
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Pick one of the pieces of the L to spawn the other...

    Make two global game attributes that keep track of L1's X and Y
    (In L1, constrain game.L1X to self.position.X...etc.)

    Then have L1 spawn L2

    In L2, constrain its position to game.L1X and game.L1Y plus the appropriate offset.
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    firemaple thanks for that.... sounds like an interesting way to do it... will it work nicely with rotation... sound like it would.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    no, it won't rotate properly...

    I believe you'll need trig for the rotation... someone just recently made a chainsaw demo that shows that...
  • ORBZORBZ Member Posts: 1,304
    If the object doesn't collide then use a rectangle with an L image and swap two pieces to form the L (bar and square) when collision occures. This way you only really have one L that moves around as the others are just illusion place holders.

    Depends on the game though. If you have a lot of L's colliding with stuff at the same time this won't work. If you only have one collision at a time this will work.
  • rebumprebump Member Posts: 1,058
    Yeah, in instance where a (parent) actor is constrained/joined to another actor(s), I usually try to have the parent actor spawn the others. Combine that with some game level attribute semaphores, and you can do what FMG has suggested.
  • homelesswombathomelesswombat Member Posts: 73
    To get them rotating together, constrain game.rotation to actor1 self.rotation angle+90. Then constrain actor2 rotation to game.rotation. If you're smart with your offsets you will get an L shaped colliding actor. I haven't tried it yet but someone correct me if I'm wrong.
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    homelesswombat....cheers for that, sound simple enough and in mind at least sounds like that would work...or crash GS, one or the other... :-)
  • homelesswombathomelesswombat Member Posts: 73
    My solution will only work with one actor, unless you want to make four separate actors and four game.variables only to yeild two actors D:

    If you intend to have only one "active" (receiving input) actor per screen, and a number of "passive" (not receiving input) actors of the same type, you could create a third actor and have the active actor destroy itself upon becoming passive.
Sign In or Register to comment.