Question for game in color switch style (endless game)

Hello everyone

I’m trying to create a game similar to the famous color switch. I am having some difficulties with the basic mechanical properties. I structured the code like this:

_A background that flows endlessly and time increases scrolling speed(vertical scroll).

_A ball that goes up every time I press on the screen.

The problem is this: if I press on the screen many times the ball too much salt and disappears from the screen. How can I fix? I’m something wrong from the beginning?

No suggestions?

Hello,

one tips is to put the ball in a group that moves in the opposite direction of the ball.

With this trick, the ball look like " fix"  on the screen, and the group and others objects inside (rocks for exemple) moves together.

local group=display.newGroup() // this group will move vertically of 5 (the speed) every frame group.x,group.y=display.contentCenterX,display.contentCenterY local square=display.newRect(group,0,0,50,50) // square is on the center of the screen local spawnRock=function(\_groupGame)   local rock=display.newRect(\_groupGame,0,0,10,10) rock.x=math.random(-display.contentCenterX,display.contentCenterX) // somewhere on X axis rock.y=square.y-display.contentCenterY // y position is finally on the top of the screen   rock:setFillColor(1,0,0) end // the rock are insert on " group " during the timer below. local speed=5 // my increment - speed timer.performWithDelay(1,function(event)     group.y=group.y+speed     square.y=square.y-speed // the group of object increase, but I smartly decrease the y position of square on the group g // so he looks like "fix" on the screen          if math.random(10)==1 then spawnRock(group) end // 10 percent probability to spawn a rock   end,-1)

And next just add Runtime touch screen to move left and right and onCollision listener to detect when hitting the rock. Don’t forgot to manage the rock oustide the screen.

Or a Runtime touch screen to dynamicaly change the speed value.

Yvan.

Thanks ivan,

Perhaps I did not explain well. I’ve made something similar to your code.

I have a group that shows objects that run in the background. The problem is that with the user tap brings the ball (something like: ball.y = ball.y  - 10).

I Would indeed: if the user does so many tap to add speed to the background but not to dump the ball off the screen.

I have: the ball out from the background screen does not change speed …

limit tap speed?  make background move inversely propotional to ball movement so ball always stays centred?

your post is too vague for meaningful comments.

I am lost too lol

I apologize if I have not explained well. Now I try again:

I create a background that moves endlessly and with the passage of time the background will go faster.

It also creates obstacles that with the passage of time appear more often.

At this point I have my ball. If the user does not touch the screen (to make up the ball) the ball comes down and loses if it leaves the screen. While if the user touches the screen many times (the ball much salt) ball disappears from the screen.

That said, I would like that if the user clicks on the screen many times, the ball does not disappear (coming up), but instead remains at the center of the screen. However since the 'user is doing a lot of tap, the speed of the background must increase

Made myself clear? Sorry for my bad English and thanks for help

I speak french, and you ? lol

Si c’est le cas, tu peux rajouter un événement " tap " qui modifie la variable speed, ça me semble le plus simple.

clear like mud… 

don’t animate your ball, instead move the background accordingly.  instead of the ball moving up in Y, make the background move down -Y

I speak Italian I’m sorry.

However, thanks to both was probably more simple than expected.

Sometimes you have the answers under the eyes but not seen…

You are not polite.

plz don’t write this

Although I think it was said in an ironic way, it would be better to avoid it. We are not all native speakers and you may be misunderstood… Me too… Anyway I solved it here better to not over talk about this. Good day…

No suggestions?

Hello,

one tips is to put the ball in a group that moves in the opposite direction of the ball.

With this trick, the ball look like " fix"  on the screen, and the group and others objects inside (rocks for exemple) moves together.

local group=display.newGroup() // this group will move vertically of 5 (the speed) every frame group.x,group.y=display.contentCenterX,display.contentCenterY local square=display.newRect(group,0,0,50,50) // square is on the center of the screen local spawnRock=function(\_groupGame)   local rock=display.newRect(\_groupGame,0,0,10,10) rock.x=math.random(-display.contentCenterX,display.contentCenterX) // somewhere on X axis rock.y=square.y-display.contentCenterY // y position is finally on the top of the screen   rock:setFillColor(1,0,0) end // the rock are insert on " group " during the timer below. local speed=5 // my increment - speed timer.performWithDelay(1,function(event)     group.y=group.y+speed     square.y=square.y-speed // the group of object increase, but I smartly decrease the y position of square on the group g // so he looks like "fix" on the screen          if math.random(10)==1 then spawnRock(group) end // 10 percent probability to spawn a rock   end,-1)

And next just add Runtime touch screen to move left and right and onCollision listener to detect when hitting the rock. Don’t forgot to manage the rock oustide the screen.

Or a Runtime touch screen to dynamicaly change the speed value.

Yvan.

Thanks ivan,

Perhaps I did not explain well. I’ve made something similar to your code.

I have a group that shows objects that run in the background. The problem is that with the user tap brings the ball (something like: ball.y = ball.y  - 10).

I Would indeed: if the user does so many tap to add speed to the background but not to dump the ball off the screen.

I have: the ball out from the background screen does not change speed …

limit tap speed?  make background move inversely propotional to ball movement so ball always stays centred?

your post is too vague for meaningful comments.

I am lost too lol

I apologize if I have not explained well. Now I try again:

I create a background that moves endlessly and with the passage of time the background will go faster.

It also creates obstacles that with the passage of time appear more often.

At this point I have my ball. If the user does not touch the screen (to make up the ball) the ball comes down and loses if it leaves the screen. While if the user touches the screen many times (the ball much salt) ball disappears from the screen.

That said, I would like that if the user clicks on the screen many times, the ball does not disappear (coming up), but instead remains at the center of the screen. However since the 'user is doing a lot of tap, the speed of the background must increase

Made myself clear? Sorry for my bad English and thanks for help

I speak french, and you ? lol

Si c’est le cas, tu peux rajouter un événement " tap " qui modifie la variable speed, ça me semble le plus simple.

clear like mud… 

don’t animate your ball, instead move the background accordingly.  instead of the ball moving up in Y, make the background move down -Y