Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local mydata = require("mydata")
- mydata.humanoids = {}
- local scrollSpeedX = 0
- function createHumanoid(layer)
- local layer = layer or display.currentStage
- for i = 1, 10 do
- local humanoid = display.newRect(0, 0, 10, 10)
- humanoid.x = math.random(-1000, 1000)
- humanoid.y = 260
- physics.addBody(humanoid, { isSensor = true })
- mydata.humanoids[#mydata.humanoids + 1] = humanoid
- end
- function updateHumanoid()
- if switchTerrain == 0 then
- if player.x <= 100 then scrollSpeedX = 0
- else scrollSpeedX = -player.x / 70
- end
- elseif switchTerrain == 1 then
- if player.x <= 100 then scrollSpeedX = 0
- else scrollSpeedX = player.x / 70
- end
- end
- for _, humanoid in ipairs(mydata.humanoids) do
- if humanoid.x then
- humanoid.x = humanoid.x + scrollSpeedX
- end
- end
- end
- Runtime:addEventListener("enterFrame", updateHumanoid)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement