Switched position.X of 2 Actors

AppsRacKAppsRacK Member Posts: 346
edited November -1 in Announce Your Game!
Can someone kindly enlighten me on how to accomplished this. It already took me some time trying to figure it out but i have no luck tonight. I've tried searching the demos and forum but i cant find anything.

Im using a prototype actor with rules like this.
>>If pressed & Game.FirstTouch = false
----->> game.firstTouch = true
----->> game.FirstX = self.positionX

>>If Pressed & game.FirstTouch = true
----->> game.SwitchedNow = True
----->> game.SecondX = self.positionX

This is where i get stuck coz all the rules i did with switchedNow = true doesnt work.

Thanks.

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Hi drahc; my first post for about 3 months! (I've been lurking tho'...)

    Try putting the last three lines above in the otherwise section.

    :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • AppsRacKAppsRacK Member Posts: 346
    Hi gyroscope. WB. Ive figured it out actually sometimes all you need is to get far from the mac for a while and come back after 30-45 mins and it will hit you. Anyway regarding your suggestion im kinda curious if its more optimized to put it on the otherwise or place it on a separate rule?
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    drahc said:
    Hi gyroscope. WB.

    Thanks!

    If you're "popping" from one state to the other and back again, it's best to put the second state into the otherwise section. I've just done a little test but a bit differently from you, hoping it's what you're after:

    Only 2 game attributes, both integer: FirstX, being the first actor's X pos; and SecondX being the second actor's X. The Rules in the pressed actor (unlocked, i.e an instance, so you can access the other actor's attributes via the Expression Editor):

    Rule: When Actor receives event: touch is pressed

    ------ then this next Rule within the first-------

    Rule: When Attribute self.position.X = game.FirstX
    Change Attribute: self.Position.X To game.SecondX
    Change Attribute: scene.Background.Actor2.Position.X To game.FirstX

    ----then in this second Rule's Otherwise section:-------

    Change Attribute self.position.X = game.FirstX
    Change Attribute: scene.Background.Actor2.Position.X To game.SecondX

    Hope that helps.

    :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • AppsRacKAppsRacK Member Posts: 346
    Thanks for the solution Gyroscope. Unfortunately i have 5 actors in the scene and i want 2 of them to exchange place when ever the user touches them. I manage to exchange their places whenever the user touches the two actor simultaneously but im still encountering a bug right now coz the touches wont reset . This is exactly what i want to achieve.

    >>First touch on 1 actor will make it a bit larger from the rest to make it stand out and appear selected.
    >>Second touch on the other actor (2nd, 3rd 4th or 5th) will initiate the switched of the 2 actor.
    >>Then the next touch will be the same as the first touch again and the cycles goes on.

    What im having right now is that it continuously exchanging places on 3rd touch onward.
  • AppsRacKAppsRacK Member Posts: 346
    Ok now i totally fixed this one out. I should have use integer in the first place in the self attribute of the actor as it is much cleaner to execute.

    Thanks gyroscope for some input.
Sign In or Register to comment.