Constraining an actor to touch, but with an offset...
I'm working on a new game, but I'm stuck with what I thought what be a simple control.
How (if possible) can i constrain an actor to touch, but with the offset of where the touch is?
So if the actor is selected, and then the player touches and drags the other side of the screen, how can I have the actor move in proportion?
It's completely baffled me, so I'd be greatly appreciative of anyones help!
Thanks, Jamie
How (if possible) can i constrain an actor to touch, but with the offset of where the touch is?
So if the actor is selected, and then the player touches and drags the other side of the screen, how can I have the actor move in proportion?
It's completely baffled me, so I'd be greatly appreciative of anyones help!
Thanks, Jamie
Comments
Hope this works,
pan_joshua
Trouble is, when the actor is pressed it makes it difficult to see it, so precise movements are nearly impossible.
I need a way of moving the actor with touch, but without pressing it.
Currently in this quest, I have a system of selecting an actor, but now i just need a way of moving it remotely... :-/
Thanks for your help pan_joshua!
Jamie
When mouse button is down:
- constrain attr: self.position.x to mouse.position.x (+ or -) [some # of pixels]
- constrain attr: self.position.y to mouse.position.y (+ or -) [some # of pixels]
@KodeRiter722 I have already said that
@KodeRiter722, Thanks for clarifying!
Thanks!
I'll keep you posted on how I get on!
thanks
Make two self attributes (of type real). Name them xOffset, and yOffset. Then add the following rule.
When Mouse button is down
--Change Attribute:self.xOffset To:self.Position.X - game.Mouse.Position.X
--Change Attribute:self.yOffset To:self.Position.Y - game.Mouse.Position.Y
--Constrain Attribute:self.Position.X To:game.Mouse.Position.X + self.xOffset
--Constrain Attribute:self.Position.Y To:game.Mouse.Position.Y + self.yOffset
I have tried all suggestions but so far, nothing seems to have been successful (But thanks for everyones contributions so far!).
Self.Position.X to device.touches.touch 1.X
Self.Position.Y to device.touches.touch 1.Y
if you want to see the actor moving to the touch instead of constraining the actor make an interpolate.
@tenrdrmer, I don't know how I've missed that, I've been searching for weeks!
Thanks for everyones contribution!