click an drag on an object to make it stretch
snortch
Member Posts: 19
Can anyone point me in the direction necessary to create an object that acts sort of like a rubber band when it has been clicked and dragged? I have a game concept I'm working through and this is one of the pieces that I'm not quite sure how to approach in gamesalad.
TIA for any suggestions - even if the answer is that its not possible.
TIA for any suggestions - even if the answer is that its not possible.
Comments
Try this on for size:
- new actor attribute "Stretching" (boolean)
- When mouse position is over actor AND mouse button is down,
Change attribute self.Stretching to true
- When mouse button is up,
Change attribute self.Stretching to false
- When self.Stretching = true,
Constrain attribute self.Size.Width to 2*abs(mouse.Position.X - self.Position.X)
Constrain attribute self.Size.Height to 2*abs(mouse.Position.Y - self.Position.Y)
Maybe that's not quite what you're going for, but you can see how it's just a matter of finding the right equation to relate the actor's size/position to the mouse position. And the above is, if nothing else, a fun toy.
Now I need to dive into some tutorials so that I figure out how to use this tool. Does anyone have a favorite that teaches the math aspects, in general, that look to be needed to accomplish this stretchiness?
Along the bottom of the screen, I have an actor 20h480w, and it will be a value slider. I would like it to size to the mouse x position when clicked. Which I have working.
on touch pressed
change self.size.width to game.mouse.position.x
constrain attribute self.Position.X to game.mouse.position.x/2
visually the slider stays in the bottom left corner 0,0, and and scales to the right. But this only works on mouse click and not click and drag. When I click and drag the bar follows the mouse and looses its position in the bottom left corner.
I was going to suggest http://gamesalad.com/wiki/how_to_gsc_drag_and_drop_movement
but with the new touch(pressed) you don't need as much work.
I have used
When dragging true
change attribute self.mouseoffsetX to (game.mouse.posX - self.size width)
constrain attribute self.size.width to max (170,min(640,game.mouse.posX- self.mouseoffsetX))
This works perfectly for the one on the left side of the screen but the right side does it the wrong way. ie I drag right and it closes left!!!!
Its pretty obvious I need to Inverse the mouse position but I have no idea how (-1), I guess???) or where to put it.
Please Help I know this isn't hard
thanks