Moving other actors on the scene

This maybe a simple thing to do but I can't seem to find an answer or determine how to do it. What I would like to do is spawn a new actor (which I have done) and then from another actor (button) have that rotate the first actor 90 degrees. What I can't seem to determine is how to access a spawned actor in a scene like in js executing a getElementByID type of function. Is there a way to do this or do I need to find another way by using scene flags and reacting to that?

Comments

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    edited July 2013
    Are you looking for something like this where you use one actor to control another?

    http://www.jamie-cross.net/?portfolio=gamesalad-simple-touch-controls

    These controls move an actor around the screen but it would be simple to use the same concept to control an actors rotation.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    @jamie_c's example is probably enough to get this working but just in case...

    The way you do this is by using a global variable, e.g. game.firstActorRotation. In the button actor, you change or constrain the value of game.firstActorRotation and then in the spawned actor, you have a behavior (no rule) that constrains self.Rotation to game.firstActorRotation.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • sneighborssneighbors Member Posts: 5
    Thank you for the response - this is what I mentioned as the alternative to making changes directly. Ideally from the example I would like to be able to click on the Right arrow and then in the click event instead of setting the flag I would want to move the Green Square directly to the Right. The issue that I have is that I will have multiple actors on the screen (cards) and depending on what the current card is I wanted to be able to rotate that single card. If there is no direct way then I can set the same type of flag to rotate 90 degrees card x if the card x is the current card - basically 2 tests in the card actor.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Let me see if I can make you a quick demo...

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • sneighborssneighbors Member Posts: 5
    If that being the case then for all 13 cards that will eventually be in place I would need a variable for that correct? I would still need to reference the current card flag in the Button to set the correct game variable; however, that should work and may be a little cleaner as the code would reside mostly within the Rotate Button actor itself.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Okay, this is the general idea. I didn't spend any time on the actual rotation math so it's very rough (the cards just spin) but I think you'll get the idea.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • sneighborssneighbors Member Posts: 5
    Thank you for the example seems as though currently then there is no way to directly interact with another actor except through a game attribute correct? I mean I could not just hide another actor without having a variable as a game attribute and having the actor reacting to that change? Just want to make sure I'm not missing something as typically in JavaScript I would have located the element and modified it's property directly.

    Thanks again for the example.
Sign In or Register to comment.