Ok so I have an object that is always moving to the right. And I want the screen view to move with it so that it is always in the middle of the screen, or at least in the screen. I have looked at examples using screenview.lua but they aren’t what I want. How do I make it so that my object is always in the middle? Thanks!
Here is my code:
---------------------------
--PHYSICS
---------------------------
local physics = require("physics")
physics.start()
---------------------------
--GROUND
---------------------------
local ground = display.newRect(0,230,5000, 20)
physics.addBody(ground, "static", {bounce = 0.1})
---------------------------
--OBJECT
---------------------------
local object = display.newRect(20,220,10,10)
physics.addBody(object, {density = 1, bounce = 0})
---------------------------
--MOVE OBJECT
---------------------------
local function moving()
object:applyForce( 0.1, 0, object.x, object.y )
object.isFixedRotation = true
end
Runtime:addEventListener("enterFrame",moving)
-------------------------------
--MAKE SCREEN MOVE WITH OBJECT
-------------------------------
-- ?????????
[import]uid: 38001 topic_id: 11699 reply_id: 311699[/import]