How To Choose The Actor Position To (Overlaps or Collides)

tanchowyeeiosapptanchowyeeiosapp Member, PRO Posts: 36
edited July 2015 in Tech Support

Hello, I'm newbie gamesalad, can everyone help for this?

Here the screenshoot: http://postimg.org/image/4tke4i7s7/

Position A and Position B is one actor, I already set the rule for the actor can move, also I already set only when touch Position A the actor can move, here the rule,


When (all)
Event: Touch is pressed
Expression: game.Mouse.Position.Y- self.Position.Y > 100
Change Attribute: self.yOffset To: self.Position.Y - game.Mouse.Position.Y
Constrain Attribute: self.Position.X To: game.Mouse.Position.X
Constrain Attribute: self.Position.Y To: game.Mouse.Position.Y + self.yOffset


Now I want set only Position A (Overlaps or Collides) Actor C, and then Actor C will destroy, Position A & Position B is one actor, I only want Position A (Overlaps or Collides) Actor C can destroy, not Position B, what should I to do for this...

Comments

  • tintrantintran Member Posts: 453
    edited July 2015

    i am pretty new to gamesalad too, so maybe there's a better solution.
    But I would make a separate actor call it knob or something, constrain its position to match your wand actor (your A and B actor) but with an offset it so that its position would always be Position A
    Change attribute self.color.alpha to 0 (to make it invisible).
    Change the Physics Collision shape to circular.

    Then inside your actor C,
    when collision when actor overlaps or collide with knob actor
    destroy

  • tanchowyeeiosapptanchowyeeiosapp Member, PRO Posts: 36

    @tintran said:
    i am pretty new to gamesalad too, so maybe there's a better solution.
    But I would make a separate actor call it knob or something, constrain its position to match your wand actor (your A and B actor) but with an offset it so that its position would always be Position A
    Change attribute self.color.alpha to 0 (to make it invisible).
    Change the Physics Collision shape to circular.

    Then inside your actor C,
    when collision when actor overlaps or collide with knob actor
    destroy

    Hi, I understand Above you mean, now I have separate 2 actor 1 for knob actor and 1 for wand actor, the question is what rule I need to set and combine knob and wand togather?

  • tintrantintran Member Posts: 453

    I dont know if there exists another way... what I currently do to make one actor move along with the other is
    constraint game.variables to position of one actor
    and then constraint position of second actor to the game.variables

  • tanchowyeeiosapptanchowyeeiosapp Member, PRO Posts: 36

    @tintran said:
    I dont know if there exists another way... what I currently do to make one actor move along with the other is
    constraint game.variables to position of one actor
    and then constraint position of second actor to the game.variables

    Not very understand what you mean, can you tell me step-by-step rule I need to set for combine Actor A and B togather?

  • tintrantintran Member Posts: 453
    edited July 2015

    @tanchowyeeiosapp said:
    Not very understand what you mean, can you tell me step-by-step rule I need to set for combine Actor A and B togather?

    add two game variables actorA_x,actor_A_y
    inside your actor A (knob),
    constraint attribute - game.actorA_x to self.position.x
    constraint attribute - game.actorA_y to self.position.y

    inside your actor B (wand)
    constraint attribute - self.position.x to (game.actorA_x + offsetx)
    constraint attribute - self.position.y to (game.actorA_y + offsety)

    offsetx and offsety are just used so you can place your actor B offsetted to any location based on actor A's position.

    now if you have rules to move you actor A, actor B will move along with actor A.

  • tanchowyeeiosapptanchowyeeiosapp Member, PRO Posts: 36

    @tintran said:
    now if you have rules to move you actor A, actor B will move along with actor A.

    I have follow the method, A and B can combine now, still have some issues, when Move A actor, B is too slow to follow, can fix this?

    Here the video,

  • tanchowyeeiosapptanchowyeeiosapp Member, PRO Posts: 36

    Can Everyone help for this problem?

  • tintrantintran Member Posts: 453
    edited July 2015

    try this.
    This might be faster I tested it and it seems faster than the method i told you about on my computer.

    remove the constraints and variables I told you about

    add a game variable called drag(boolean), touchoffsetx and touchoffsety(reals)
    Inside actor A.
    if touch is pressed

    • change attribute game.drag to true
    • change game.touchoffsetx to (self.x-game.touch1.x)
    • change game.touchoffsety to (self.y-game.touch1.y)
      else

    • if touch is released

      • change attribute game.drag to false
        Inside actor B.
        if game.drag is true
        -- constrain self.x to (game.touch1.x+game.touchoffsetx + YOUROFFSETX)
        -- constrain self.y to (game.touch1.y+game.touchoffsety + YOUROFFSETY)

    I have attached a sample project so you can test it out and see if it's fast like how you want it

    Let me know if it's faster on yours, on mine it seems to do a pretty good job can't see the wand detach from the knob.

  • tanchowyeeiosapptanchowyeeiosapp Member, PRO Posts: 36

    @tintran said:
    try this.
    This might be faster I tested it and it seems faster than the method i told you about on my computer.

    remove the constraints and variables I told you about

    add a game variable called drag(boolean), touchoffsetx and touchoffsety(reals)
    Inside actor A.
    if touch is pressed

    • change attribute game.drag to true
    • change game.touchoffsetx to (self.x-game.touch1.x)
    • change game.touchoffsety to (self.y-game.touch1.y)
      else

    • if touch is released

      • change attribute game.drag to false
        Inside actor B.
        if game.drag is true
        -- constrain self.x to (game.touch1.x+game.touchoffsetx + YOUROFFSETX)
        -- constrain self.y to (game.touch1.y+game.touchoffsety + YOUROFFSETY)

    I have attached a sample project so you can test it out and see if it's fast like how you want it

    Let me know if it's faster on yours, on mine it seems to do a pretty good job can't see the wand detach from the knob.

    The Actor B when score down, it will disappear...everyting okey, The method is good, only the Actor B disappear when score down...

  • tintrantintran Member Posts: 453
    edited July 2015

    @tanchowyeeiosapp ,

    This disappearing only seems to happen when you're using default actors without images.
    If you add images it looks to fine. check this one out

Sign In or Register to comment.