How can I press a button (actor) and have another actor move ?
xyloFUN
Member Posts: 1,593
Howdy,
my coffee has not kicked in yet ....
How can I click on a button (actor) and have another actor holding an image moves 50 pixels left.
When I click the button again, the image moves another 50 pixels left ....
I've looked for a tut ... but for some reason nothing suitable popped up!
If anyone can help me with this, I'd be very grateful!
P.S. Even pointing me to a tut will do ... i love to learn
my coffee has not kicked in yet ....
How can I click on a button (actor) and have another actor holding an image moves 50 pixels left.
When I click the button again, the image moves another 50 pixels left ....
I've looked for a tut ... but for some reason nothing suitable popped up!
If anyone can help me with this, I'd be very grateful!
P.S. Even pointing me to a tut will do ... i love to learn
Comments
Here is what I need to do ...
When i click on an actor, I want another actor or move x units in one direction
Do I need to read up an "joystick" control tutorials or is this something different?
So far, I haven't found a tut that covers that. - thanks
yes. I want to click once and have an image move down say 50 pixels. When I click again, I'd like to move another 50 pixels .... repeat that as necessary
Also, do you know how I can cover an actor so that once it is bellow another actor, it is no longer movable?
First create two actors (one the button, the other the object). Then create an attribute like ButtonTouch can be an integer and a value of zero.
Click on the button actor and create a rule 'when actor is touched' and add a behavior 'change attribute' and select the attribute ButtonTouch and change to 1.
Then click on the object actor and create a rule 'when attribute "ButtonTouch is 1' ... add a behavior 'Move to' and select Self.PositionX +50, a Y position which will match the height the object is already at and a speed.
then also add a 'change attribute' and change ButtonTouch back to zero.
I believe that should be all you need.
that is excellent!
I will tend to this in a minute ... first i have to figure out why my piano keys are flying up in the air after playing for a few minutes??????
I made the two buttons you suggested!
Where do I create the attribute "ButtonTouch" in the scene or on one of the 2 buttons??
Also, navigating to "Self.PositionX is hard because I can't type it in like in ActionScript. Maybe it was not possible to do because the attribute was not created correctly in the first place? I created it in the scene ... was that wrong?
thanks :0
The Self.Position.X part you get when adding the moveto behavior ... where it show position: and a right arrow (ie: X axis) click on the 'e' .. then teh first down triangle and it should show three (or more items ... Game, Devices and then Actor names). select the Actor in which you are applying the behavior then Position in the next column that loads and then the X in the next column that shows. You will likely need to double click to get that to load into the field and then click the 'green tick' to apply
THANK YOU for clearing that up and adding the extra information!
I was not able to get it working but because there has been so much information posted and daily more new users start to work with gamesalad, it would be an advantage and do it proper. In order to save you the typing, I will write out the tutorial and hopefully you or another kind soul will fill in the details
Goal:
Have 2 buttons in a scene that move an image on the Y axis up or down by 50 pixels as often as clicked
1) add two actors to your scene, call one button and the other picture
2) click on "Attributes" (beside Actors) and add and integer attribute with a value of 0
3 rename the attribute ButtonTouch (double click to rename)
4) double click the button actor which will open the attributes window bellow the button and to the right of the screen and new page where you can enter rules needed to give an actor functionality
5) create a new rule > Actor receives event > touch > pressed
6) drag "Change Attribute" behaviour into that rule: Change Attribute: game.Button.Touch ... > 1
Click the back arrow (left upper screen) once to leave the button attribute window
7) double click the actor names "picture (the second one we added at the beginning)
8) add a rule > Attribute > game.Button.Touch ????? (i'm lost how to do this step?????????)
9) drag an "Move to" behaviour onto the rule and select (again self. is not an option so I assume "Game" to begin with ????? can you please clarify this as well??
Please add what ever needs to be done to complete still
I know this is not easy but for those of us who are new to GS, this will help a lot so BIG THANKS for finishing this ))
7) create a second rule >Actor receives event > touch > released
8) drag "Change Attribute" behaviour into that rule: Change Attribute: game.Button.Touch ... = 0
9) double click the actor names "picture (the second one we added at the beginning)
10) add a rule and change the 'Actor receives event' (pulldown) to Attribute click the '...' part select 'Game' then 'ButtonTouch' set it to = 1 (which means when the attribute ButtonTouch is equal to one ie: the button has been pressed)
11) drag a moveto into that rule where it shows 'position:' and a right arrow (ie: X axis) click on the 'e' .. then the first down triangle and it should show three (or more items ... Game, Devices and then Actor names). select the Actor (which gets named 'self' automatically) in which you are applying the behavior (picture) then 'Position' in the next column that loads and then the 'X'in the next column that shows. You will likely need to double click to get that to load into the field, then type +50 and then click the 'green tick' to apply. so it should look like this: Self.Position.X +50
think that should do it. Work it thru and come back for further clarification if need be so we can get the instructions clear.
Make 2 button actors, one for up and the other for down.
Put the following rule in the UP button:
When touch is pressed, change attribute game.up to 1....OTHERWISE, change attribute game.up to 0
Put the following rule in the DOWN button:
When touch is pressed, change attribute game.down to 1....OTHERWISE, change attribute game.down to 0
Next go into your moving actor
Put in the following rules:
1. When attribute game.up=1
change attribute: self.position.Y to self.position.Y+50
OTHERWISE....change attribute game.up to 0
2. When attribute game.down=1
change attribute: self.position.Y to self.position.Y-50
OTHERWISE....change attribute game.down to 0
If you wanted a left and right button then you would do the same but using the X axis rather then the Y axis...
And you do not have to use the move to behavior. Remember, the position of the actor is an attribute itself...take advantage of that
I just made a demo right now, its not letting me upload for some reason tho....email me at artonskyblue(@)gmail(dot)com and I can send over the game file to you if you still haven't worked everything out...
EDIT:
OOPS already got beat to it!
this will help me a lot guys
But no matter how I tried, this is the best way to let user "make" or create the songs!
I hope that I can give you a copy once it's done to do some testing? I really appreciate all the help and time you guys have given me
In this case I think you need to create an attribute say 'Picture2_move' and set it to 1 (1 will mean Picture2 can be moved. Then put you move code into a rule which say when attribute 'Picture2' = 1 ... then the move code will run.
You will then need to create an attribute for Actor1 positionX and Actor1 positionY and have Actor1 code assign its self.position.x to the appropriate attribute and self.positionY likewise.
Lastly you would create a rule for Picture2 that says when attribute self.position.x = attribute Actor1_positionX and a second condition of that rule when self.position.Y = attribute Actor1_positionY then drag change attribute and have it set attribute Picture2 to 0.
thus when the images are in the same position attribute Picture2 is 0 which will not allow you move code to execute.
Haven't tried it myself but thought it would give you a place to start and for others to redirect you if I'm on the wrong tack.
it's more or less DONE!! YAY
If I can figure out why the iPad does not shut off when I run my own app AND when I close the app, WHY it does not start from scene one ... than I'm more or less ready to submit (did a lot of reworking everything)
Again, thanks! I could have not done this much without your help