Okay so I’ve been working on making a game with a character that can explore a map and the camera follows it. So I made a 1440 x 960 image and displayed it in the simulator. I then created a square for a simple character and made it a static object (also setting the gravity to 0,0 ) so it stays in the center of the screen at all times.Then I put all the objects but the character into a display group called game. I then (using the lib_analog_stick code -http://developer.anscamobile.com/code/simple-analog-stick-joystick-module) made the display group move in the opposite direction making it look like the character was going through the map.
My troubles start here:
I added another block and made it a static physics body then inserted it into the display group game. But when I played my game the character doesn’t act like it hit anything when it really did.
Am I doing something wrong or have I left anything out?
-Thanks
-Here’s my code-
[code]
–instead of a background image here’s a couple blocks for reference points
local b1 = display.newRect(0,0,20,20)
b1:setFillColor(0,255,255)
b1.x = 500
b1.y = 0
game:insert(b1)
local b2 = display.newRect(0,0,20,20)
b2:setFillColor(0,255,255)
b2.x = 0
b2.y = 500
game:insert(b2)
local b3 = display.newRect(0,0,20,20)
b3:setFillColor(0,255,255)
b3.x = 0
b3.y = 0
game:insert(b3)
local b4 = display.newRect(0,0,20,20)
b4:setFillColor(0,255,255)
b4.x = 500
b4.y = 500
game:insert(b4)
–character
local ship = display.newRect(0,0,20,20)
ship:setFillColor(0,0,255)
ship.x = 160
ship.y = 240
physics.addBody(ship,“dynamic”)
– The non-working obstacle
local block = display.newRect(0,0,20,20)
block:setFillColor(255,0,255)
block.x = 200
block.y = 240
physics.addBody(block,“dynamic”)
game:insert(block)
–heres the joystick (requires lib_analog_stick file)
local StickLib = require(“lib_analog_stick”)
MyStick = StickLib.NewStick(
{
x = screenW*.1,
y = screenH*.85,
thumbSize = 16,
borderSize = 32,
snapBackSpeed = .75,
R = 255,
G = 255,
B = 255
} )
local function move1( event )
MyStick:move(game, -5, false)
end
Runtime:addEventListener( “enterFrame”, move1 )
[import]uid: 113909 topic_id: 27592 reply_id: 327592[/import]
