Touch and scale actor
Hi everybody.
I need some help on the following:
i want to drag and scale an actor, i managed to do it, but the problem is that when i touch
my actor, it scales sudden according to the area of the touch. I don't know if it is clear enough.
I need some help on the following:
i want to drag and scale an actor, i managed to do it, but the problem is that when i touch
my actor, it scales sudden according to the area of the touch. I don't know if it is clear enough.
Comments
Hi, I'm guessing you've got both sets of Rules - for drag and scale - all working on touch, so they'll start working at the same time. So you need some sort of separation; your drag rules will work OK on the touch rule of course, but then you'll have to work in some kind of system to let the rules "know" the actor needs to be scaled.
What this system is would depend on what kind of game or app you are making.... if it's some sort of utility for instance, one system would be to have a button at the side that when pressed, highlights the actor perhaps, and when touched scales the actor accordingly.
It's difficult to be more precise without knowing what sort of thing you're creating...
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
I want to have an image on my scene, i will have 3 options, move, scale, rotation.
I fixed the move and rotation issues, i also fixed the scaling. but (like rotation that fixed) when you touch the actor, for scaling, it takes the number of x,y of touch and converts it to scaling x,y, The problem is that this scaling does not start the scaling from the current actors scaling but it depends on the x,y of the touch.
Imaging that i want to make an application like a photo studio or something. not a game. I don't know how to explain it better...i apologize...
The same thing needs to happen with scaling. In this case you would determine the distance from the center of the actor to the touch point (use magnitude function). Then you add (or maybe subtract) that offset distance into the scaling equation you have.
Here is a previous thread that might help:
http://forums.gamesalad.com/discussion/44456/pinch-spread-rotate
i created a self-distance attribute which is constrained to
magnitude( game.Touches.Touch 1.X - self.Position.X , game.Touches.Touch 1.Y - self.Position.Y )
then i constrain self.size.width TO self-distance
same thing for Height.
The problem is still there, if i press in the middle of the actor, the actor gets real small,
then when i drag it gets bigger or smaller. So the problem is at my first touch. I don't need two finger scaling at this time, but the preset you linked me to, for sure it will be very useful for me in the near future...so thanks anyway.
It must be something stupid, but since i am a begginer, i am really confused with this, it is one of the lasts things to fix before publishing my app.
Constrain: self.size.Height To: (self.size.Width + (self.size.Width - self.distance))
any ideas?
Make three 'real' attributes in the actor: widthOffset, heightOffset, and distance.
Add this rule to the actor:
When touch is pressed
--Change Attribute: self.widthOffset To: (magnitude( game.Mouse.Position.X - self.Position.X , game.Mouse.Position.Y - self.Position.Y )- self.Size.Width )
--Change Attribute: self.heightOffset To: (magnitude( game.Mouse.Position.X - self.Position.X , game.Mouse.Position.Y - self.Position.Y )- self.Size.Height )
--Constrain Attribute: distance To:magnitude( game.Mouse.Position.X - self.Position.X , game.Mouse.Position.Y - self.Position.Y )
--Constrain Attribute: self.Size.Width To:self.distance - self.widthOffset
--Constrain Attribute: self.Size.Height To:self.distance - self.heightOffset
Notice that there are two Change Attribute behaviors and three Constrain Attribute behaviors
Hope this helps!
I just send my imac for screen replacement and i also leave for vacations, i will try what you suggest as long as i am back. I really appreciate your help.
Hope it works out for you.