camera problem...
beatrage
Member Posts: 126
I am making a game that when you hold the cursor(mouse/touch) down the main character is going to walk to that drection as long as you hold the mouse down...
but the main problem here is the initial piece of the first camera/first 480x320 that when I hold the mouse to the right portion next to character is making him go to the left side and not the right side and the interresting thing is as long as you hold the button and he surpasses the first camera/view he normalizes his position...and...even if I grab the camera and make it bigger or shorter it even gives the same results...
also the worst part and my main nightmares is this:
I have all the sprites from my completed game (that i´ve done on GML) and when I try to make the moving position goes from 50 to 110( Y axis) when I am at this 2 position my character runs smooth with a constrained rule that make his Y axis from 110 to (if self position is greater than 110 )self.position.y = 110 and on the 50 position to go to (if self position is less than 50 )self.position.y = 50 ...but between this to positions I don´t know what kind of rule I could create to make my character stop going a little up and down, all the time he starts walking to the right or to the left.
It´s like you have to create a rule for all the Y positions between 50 to 110 to make him walk smooth by obligating him to use the walking sprite.
I even created atributtes like:
UP = if heroy is less than game.mouse.position.y
up = true
down = false
DOWN = if heroy is greater than game.mouse.position.y
down = true
up = false
RIGHT = if heroy less than game.mouse.position.x+camerax (here i had to put heroy and not herox because if I did that my camera would stop before the first 480x320 i don´t know why!!)
right = true
left = false
LEFT = if heroy less than game.mouse.position.x+camerax
left = true
right = false
camerax = constrain game.mouse.position.x
cameray = constrain game.mouse.position.y
herox = constrain self.position.x
heroy = constrain self.position.y
in my GML game I have more than 60 pages of programing(all done by me) and on GS even with this configuration and my programing knowledge I can´t !I am taking a beat of this APP...What I am doing wrong here? LOL( just laughing not to cry )^_^
but the main problem here is the initial piece of the first camera/first 480x320 that when I hold the mouse to the right portion next to character is making him go to the left side and not the right side and the interresting thing is as long as you hold the button and he surpasses the first camera/view he normalizes his position...and...even if I grab the camera and make it bigger or shorter it even gives the same results...
also the worst part and my main nightmares is this:
I have all the sprites from my completed game (that i´ve done on GML) and when I try to make the moving position goes from 50 to 110( Y axis) when I am at this 2 position my character runs smooth with a constrained rule that make his Y axis from 110 to (if self position is greater than 110 )self.position.y = 110 and on the 50 position to go to (if self position is less than 50 )self.position.y = 50 ...but between this to positions I don´t know what kind of rule I could create to make my character stop going a little up and down, all the time he starts walking to the right or to the left.
It´s like you have to create a rule for all the Y positions between 50 to 110 to make him walk smooth by obligating him to use the walking sprite.
I even created atributtes like:
UP = if heroy is less than game.mouse.position.y
up = true
down = false
DOWN = if heroy is greater than game.mouse.position.y
down = true
up = false
RIGHT = if heroy less than game.mouse.position.x+camerax (here i had to put heroy and not herox because if I did that my camera would stop before the first 480x320 i don´t know why!!)
right = true
left = false
LEFT = if heroy less than game.mouse.position.x+camerax
left = true
right = false
camerax = constrain game.mouse.position.x
cameray = constrain game.mouse.position.y
herox = constrain self.position.x
heroy = constrain self.position.y
in my GML game I have more than 60 pages of programing(all done by me) and on GS even with this configuration and my programing knowledge I can´t !I am taking a beat of this APP...What I am doing wrong here? LOL( just laughing not to cry )^_^
Comments
This may help with larger scene sizes:
http://gamesalad.com/wiki/how_to_gsc_drag_and_drop_movement#modifications_for_non-default_scene_size
If you want to figure this out yourself, create 2 actors in a scene that has a width of 10000.
Actor 1:
- Display Text: game.mouse.position.X
Actor 2:
- Display Text: self.Position.X
- Control Camera
- Move (to the right)
Put Actor 1 in a non-scrollable layer, and Actor 2 in a scrollable layer.
Playing this scene in the preview player you can see a couple of things.
1. The actor moving right is displaying its X position that increases up to 10000 and loops back or 0 after that.
2. No matter how far the camera goes, the mouse position is always relative to the camera origin. So the position of the mouse at the bottom left corner of the camera view is always (0,0).
So what this means is that if you want your moving actor to go to a position given the mouse position, you will need to add the camera's origin position as an offset. And if you follow the directions up to number 5 in the link above, that should help out.
Unrelated, and this goes for everyone, please try to create your posts in the correct forums when create new topics. Thanks.
Thanks now I´ve reached the real actor!
if anyone is having doubts here the main problem on the tutorial is the fact that you ned to create an actor with 2 constrain game attributes behaviors 'OffsetX'and 'OffsetY' to 0 and... put this actor on the background to the right...after that you have to click 2 times on that actor to open the locked screen edit mode and click on the locker to open it and edit THIS actor(and not the main actor that generated this one)..after that create 2 constrain game attributes behaviors'OffsetX' and 'OffsetY' to Origin X and Y, respectively. NOW ..You will find this under 'Current Scene → Camera → Origin' because if you try to open this option on the main actor that generated this one...YOU WON´T FIND IT!! and that´s it folks!!
thank you for the hint above CodeMonkey !!
There's multiple forums?? I just look at the most recent list. Didn't know there were multiple forums
if I use conditions like on my actor :
if self.position.x is less than game.mouse.position.x
or
if self.position.x is less than game.mouse.position.x+offsetx
or
if game.mouse.position.x is greater than self.position.x
on my mouse down condition on a background moveable actor with a resolution of 2880x320 on a scrollable layer scene!
IF I click and hold the mouse cursor to the right of my actor he starts walking to the right...but after scrolling the background when I reach the position >=960 my character starts kicking his animation to the right like he is blocked(with my cursor at the right end of the screen and IF I push the mouse outside the screen to the right position while still holding it the character moves a bit more to the right...but then stops at 1500 like he is blocked again...and he can´t reach the <=2880 position of my scene...
BUT
If I change the conditions above to:
if self.position.Y is less than game.mouse.position.x(changed theself position X to Y )
He goes all the way to the right with my pressed down cursor/mouse with no problems...but the camera area gets messed and I can only move my character to the left with the same condition touching/clicking at postions like:
cursor positions on screen from (game.mouse.position.X 0 to 480 on the camera view):
click and hold on position < 100 goes to the left
click and hold on position > actor self.position.x goes to the right
and if my character is at 2880 I need to click at game.mouse.position.X on scrren at <100 to start moving to the left...so what can I do here to tell the game that when I click in any position to the left I GO LEFT and any position to the right I GO RIGHT...because the condition self.position.X of my actor seems not to be working with my game.mouse.position.X??
could you help me on this one?I am spending more than 2 weeks to masterize perfectly the touch moving for the iphone...even with events like mouse position over and not over the actor I already did!
If I am posting in the wrong sections I apologize...I am really sorry!
I am just too excited about GS that´s it I´ve said it ^_^
you would help a lot of people here...including myself ^_^
yesterday I have mastered the objects offsetx and offsety and now I can control perfect my main character with the mouse on any direction!!
thanks to CodeMonkey´s hint!!
now let´s work on thecreation of an actor bouding box for perfect colisions!!