hello,
In the normal parallax you move your map on both direction
is it possible to make just one direction scrolling : x or y ?
thank you
:=)
A fast, easy to use, free, and community supported 2D game engine
hello,
In the normal parallax you move your map on both direction
is it possible to make just one direction scrolling : x or y ?
thank you
:=)
You can do it yes, but if you want to do a continuous scrolling then it'll be a PIA. Maybe it was due to my limited skills, but I initially tried to do a side scroller using parallax and found that I had to micro manage and increment my X coordinate for placement of items as I moved. Meaning, as I moved along the X axis in my world, the value continuously increments. So now if I wanted to spawn baddies at certain points then they would have an X location of like 3000 for instance...and so on. I probably missed how to easily do it but that's what I had experienced when looking into it. And it just seemed to be tougher than it should've been.
You can scroll your parallax node along a single X or Y axis if you like, there is nothing that says you have to move along both axes. I use the Parallax node for a continuous scrolling background but I only use it for the background. I use a single CCMoveTo action on the parallax node and that's all it takes to move the background for the entire gameplay of the level. I have three TMX tile maps in my parallax node that all move at slightly different rates.
I spawn my enemies based on a timer going off. I have an array of events and each event has a "time to next event" item. I use a timer to decrement the time to next event and when it reaches 0 then I trigger the next event. Events can be anything from spawing an enemy to triggering a sound effect.
after all your explanations ( i thank you all )
i reached to this : i don't know if it is correct
but at least it can solve in a way this problem
if anyone has it the same as me
//-----------------------------------
-(void) ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"moving***********************************************");
UITouch *touch = [touches anyObject];
CGPoint touchLocation = [touch locationInView: [touch view]];
CGPoint prevLocaiton = [touch previousLocationInView:[touch view]];
touchLocation = [[CCDirector sharedDirector] convertToGL:touchLocation];
prevLocaiton = [[CCDirector sharedDirector] convertToGL:prevLocaiton];
CGPoint diff = ccpSub(touchLocation, prevLocaiton);
CCNode *node = [self getChildByTag:MyNodeTag];
CGPoint currentPos = [node position];
CGPoint movePos = ccpAdd(currentPos, diff);
//[node setPosition:ccpAdd(currentPos, diff)];
// move only on y
[node setPosition:ccp(node.position.x, movePos.y)];
}
//-----------------------------------
:=)
The code moves objects on the screen. Is that what you want? I thought you were trying to move the background with parallax scrolling. If it is, you might want to take a look at this thread: http://www.cocos2d-iphone.org/forum/topic/4883#post-29146
You must log in to post.