Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Score and Gravity
Started by delimasyon Oct 11 2017 08:56 PM

1 reply to this topic
gravity score physics scores gameover level high score game gaming app

Best Answer delimasyon , 12 October 2017 - 01:49 PM

Ok.  I solved myself.

 

I have put the code in ''Collision'' (enemy) section. That works.

timer.cancel(updatePhysics)

[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

delimasyon

[GLOBAL: userInfoPane.html]
delimasyon
  • Observer

  • 7 posts
  • Corona SDK

Hi,
 
I want to do in my game, when score reached specific number, increase gravity. I did it.

 

If i restart the game in game over menu there is no problem but if i back to the main menu  from game over screen then start game, gravity is still same, fast when i reached last score.

 

How can i completly reset Gravity values when game over.

 

If you help me as soon as possible i will be so pleased.
 

--initial game setup 
function scene:show( event )
	if event.phase == 'did' then
		lastElapsed = (system.getTimer() -2000)
		local group = self.view
		gui = display.newGroup()
		gui.back = display.newGroup()
		gui.front = display.newGroup()
		gui.overlay = display.newGroup()
		gui:insert(gui.back)
		gui:insert(gui.front)
		gui:insert(gui.overlay)

		physics.start()
		
		physics.setGravity(0,9)

local updateScore
local updatePhysics
local update = function()
	if (score > 3) then
	physics.start()
	physics.setGravity(0,13)	
	if (score > 40) then
	physics.start()
	physics.setGravity(0,15)
	if (score > 60) then
	physics.start()
	physics.setGravity(0,17)
	if (score > 80) then
	physics.start()
	physics.setGravity(0,18)
	if (score > 100) then
	physics.start()
	physics.setGravity(0,19)
	if (score > 120) then
	physics.start()
	physics.setGravity(0,20)
	if (score > 140) then
	physics.start()
	physics.setGravity(0,22)
	if (score > 160) then
	physics.start()
	physics.setGravity(0,23)
	if (score > 180) then
	physics.start()
	physics.setGravity(0,24)
	if (score > 200) then
	physics.start()
	physics.setGravity(0,24)
	if (score > 220) then
	physics.start()
	physics.setGravity(0,25)
	if (score > 240) then
	physics.start()
	physics.setGravity(0,26)
	if (score > 260) then
	physics.start()
	physics.setGravity(0,27)
	if (score > 280) then
	physics.start()
	physics.setGravity(0,28)
	if (score > 300) then
	physics.start()
	physics.setGravity(0,29)
	if (score > 320) then
	physics.start()
	physics.setGravity(0,30)
	if (score > 340) then
	physics.start()
	physics.setGravity(0,31)
	if (score > 360) then
	physics.start()
	physics.setGravity(0,32)
	if (score > 380) then
	physics.start()
	physics.setGravity(0,33)
	if (score > 400) then
	physics.start()
	physics.setGravity(0,34)
	if (score > 420) then
	physics.start()
	physics.setGravity(0,35)
	if (score > 440) then
	physics.start()
	physics.setGravity(0,36)
	if (score > 460) then
	physics.start()
	physics.setGravity(0,37)
	if (score > 480) then
	physics.start()
	physics.setGravity(0,38)
	if (score > 500) then
	physics.start()
	physics.setGravity(0,40)
	end
	end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
updatePhysics = timer.performWithDelay(1000, update, 0)



		physics.setDrawMode("normal") -- normal, debug, or hybrid

		runtime = 0
		runtimez = 0

		spawnTime = starting_freq

		w = display.screenOriginX+display.actualContentWidth
		h = display.screenOriginY+display.actualContentHeight

		animColor = nil



[TOPIC: post.html]
#2

delimasyon

[GLOBAL: userInfoPane.html]
delimasyon
  • Observer

  • 7 posts
  • Corona SDK

  Best Answer

Ok.  I solved myself.

 

I have put the code in ''Collision'' (enemy) section. That works.

timer.cancel(updatePhysics)



[topic_controls]
[/topic_controls]