i need help please with constraining actor position to touch position .
guilleface
Member Posts: 1,014
i don't know why is not working but this is the problem , my game are is 480 wide x 320 high and say i have some tiles in this area, so when i touch one of them my hero actors changes position where i touch, but my complete game are is 960x640 so i have some arrows to move the camera and when the camera is outside i guess of 480x320 the touch no longer works any idea why?
Comments
when grid is touched
change game.herox. to mouse.position.x+camx
change game.heroy. to mouse.position.y+camy
the problem is that i can click at any edge of my grid actor and the hero is not in the center of the grid.
so this is how my game rules was setup first..
first i create a self attribute on my grid actor, "distance"
now when grid is touch
change self.distance to magnitude(self.positon.x-mouse.position.x,self.position.y-mouse.position.y) then second rule
when self.distance is <20
game.herox to self.position.x
game.heroy to self.position.y
the magnetite is to prevent for touching two grids or to make my hero to be always in the center of the grid.
so i try to add the +camx in the magnitude rule after mouse.position but is not working , i tried many options but nothing.
grid rules
https://dl.dropbox.com/u/46439975/Screen Shot 2012-11-02 at 4.19.07 PM.png
heror rules
https://dl.dropbox.com/u/46439975/Screen Shot 2012-11-02 at 4.21.13 PM.png