Actor triggering not working correctly

I am very new to gamesalad. I am trying to understand how Gamesalad works.


I have 3 actors: "box" is 300x100 pixels, "accent" is 50x50, and a "button".

What I am trying to eventually achieve is to position 1 "accent" at each corner of "box" and have them mirrored and rotated so that they all point the the center of "box". These will eventually be affected by other controls to further change their position to each other, rotation, and other things. However I have run into a problem.

I have very specific reasons for approaching this like I have, so I need to see if I be successful using the following approach.

The following code is all done with prototypes. The instance options are all locked.

When the button is pressed (touch event), game variable "doChange" is set to 1 until button is released. On release, doChange is set to zero.

When the touch event happens (and doChange=1) the following occurs:
1) There is a rule in "button" that spawns 3 more copies of "accent" and assigns an actor level index value to each "accent", numbering 1-4. This seems to work.
2) There is a rule inside "box" that stores its x,y and height and width in 4 game level variables (boxX, boxY, BoxHeight, BoxWidth). This seems to work.
3) There is a rule inside "accent" that if "doChange=1" and "self.myIndex = 1" then change attribute of self.position.x to game.BoxX and self.position.y to game.BoxY.

This last part is where the problem occurs. I have a display text event in "Box" to show the value of "boxX", so I know the value is stored. However, the "accent" with "myIndex" value of 1 is not moved to x,y position of box. It moves to the bottom left hand corner of the scene. I did try typing in the name instead of selecting it from the list, but this cause the actor "Accent" index 1 to move to the upper left hand corner of the scene.

If I type in the actual value of the "Box" X,Y into the change attribute command of "Accent" index 1, the actor is positioned correctly. However, if I try to reference the game variable to preform a change attribute, it doesnt work.

All name are selected from lists instead of being typed in.

I apologize if I am not being sufficiently clear.

If anyone has any suggestions, I would greatly appreciate it.

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    It's clear. :)

    Are you using Change Attribute to set the position of the accent actors? It sounds like you're using a behavior with "Relative to" set to actor instead of scene.

    If you'd like to provide a download link to your project file (.zip it first), I can take a look at your rules. Or you can post screenshots of the rules. It sounds like you have it set up correctly for the most part so it shouldn't be too difficult to fix.

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

  • lyinggodlyinggod Member Posts: 2
    The issue is not a "Relative to" issue. One rule set creates the spawn and a completely different rule sets the first accent actor position.x = game.boxX (which doesnt work). This may not be the best way to do things, but I am still figuring the software boundaries and limitations.

    You should be able to DL my file from http://nordicforgesigns.com/salad/salad.zip

    Thanks - Any help is appreciated
  • lyinggodlyinggod Member Posts: 2
    Oh, the files doesnt quite match the names I gave above as I rebuilt it from scratch thinking it might be a corrupted file or something I added without realizing it.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    The problem is that you have two rules in two actors running at the exact same time:

    When game.doChange=1
    Change self.position.X to game.signX
    Change self.position.Y to game.signY

    When game.doChange=1
    Change game.signX to self.position.X
    Change game.signY to self.position.Y

    To fix this, add a timer around the top set of Change Attribute behaviors with it set to After 0.1 seconds and with run to completion checked.

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

Sign In or Register to comment.