Hi Alex, I have setup a seperate lua file called gameConfig and its allowing me to call my player settings in menu.lua except without its properties such as physics body (I turn the body to dynamic and it doesn’t drop or anything) and also the movePlayer function creates a global event = nil error, which should move the player on the menu screen.
gameConfig.lua
local M = {} Anims = { "images/birdAnim.png", "images/birdAnim2.png", } local sheetData = {width=45, height=35, numFrames=2, sheetContentWidth=90, sheetContentHeight=35} local imagesheet = graphics.newImageSheet(Anims[math.random(1,2)], sheetData) local sequenceData = { {name="hop", start=1, count=1, time=300}, {name="drop", start=2, count=1, time=300} } local function createBird() bird = display.newSprite(imagesheet, sequenceData) bird.x = display.contentCenterX - 150 bird.y = 140 bird.name = "bird" bird.bodyType = "dynamic" bird.isFixedRotation = true bird.isSensor = true bird:setSequence("drop") bird:play() end local function movePlayer(event) if event.phase == "began" then bird:setLinearVelocity(0, -flapForce) playSFX(sndJump) bird:setSequence("hop") bird:play() elseif event.phase == "ended" then bird:setSequence("drop") bird:play() end return true end M.createBird = createBird M.movePlayer = movePlayer return M
Menu.lua
local storyboard = require( "storyboard" ) local scene = storyboard.newScene() local physics = require "physics" physics.start() physics.setGravity( 0, 50 ) local status = require("gameConfig") local flapForce = 350 gameConfig.createBird() gameConfig.movePlayer()