Yeah my player variable is created in my main game file called level1.lua here
[lua]function drawPlayer()
– Load Player
playersheet = sprite.newSpriteSheet(“squid.png”, 150, 43)
– Our sprite sheet
– 32 is the width of each “box”, this is the image width divided by the number of images across
– 36 is the height of each “box”, this is the image height divided by the number of images down
playerset = sprite.newSpriteSet (playersheet, 1, 2)
sprite.add (playerset, “playerleft”, 2, 2, 300, 0)
sprite.add (playerset, “playerright”, 1, 1, 300, 0)
– The sprite set uses images 1 to 12 (all of them)
– “heroup” starts at image 1 and includes 3 frames. (In this case 1, 2, 3.)
– The “300” indicates .3 seconds per frame, the “0” indicates it will repeat until we stop it.
player = sprite.newSprite (playerset)
player.x = 300
player.y = 1700
– We insert out hero sprite
player:prepare(“playerright”)
–Load initial camera shot
camera:insert(player)
camera.x = -player.x
camera.y = -player.y + 260
physics.addBody( player, { isSensor = true } )
end[/lua]
And is needed in my joystick control file called star.lua
[lua]------------------------------------------------------------------------------------------------------------------------
module(…, package.seeall)
local function movePlayer( xStrength , yStrength )
– Set Plane Speed Mutliplyer
local speed = 8
– Move X
if xStrength ~= false then
player.x = math.floor( player.x + ( xStrength * speed ) )
end
– Move Y
if yStrength ~= false then
player.y = math.floor( player.y + ( yStrength * speed ) )
end
– Boundries
if player.x < 30 then
player.x = 30
elseif player.x > 1690 then
player.x = 1690
end
if player.y < 220 then
player.y = 220
elseif player.y > 1700 then
player.y = 1700
end
end
function playerControl( event )
local joyX = event.joyX
local joyY = event.joyY
local joyAngle = event.joyAngle
movePlayer( joyX , joyY )
animatePlayer( joyAngle )
– rotatePlayer( joyAngle, joyX )
end [/lua]
This works fine without directors class. Where would I call yourfilename.player?
Cheers [import]uid: 26289 topic_id: 13398 reply_id: 49201[/import]