Help with touch events

main.lua

--Hide status bar from the beginning display.setStatusBar( display.HiddenStatusBar ) require("maps.map1")

controls.lua

-- Add left button left = display.newImage ("images/left.png") left.x = 15; left.y = 270; -- Add right button right = display.newImage ("images/right.png") right.x = 65; right.y = 270; -- Add up button up = display.newImage ("images/up.png") up.x = 40; up.y = 245; -- Add down button down = display.newImage ("images/down.png") down.x = 40; down.y = 295;

maincharacter.lua

--Variables to set characters X and Y cords to the center of the screen local centerXcord = display.contentCenterX local centerYcord = display.contentCenterY --Display character character = display.newImage( "images/character.png" ) --Move character to center of screen character.x = centerXcord character.y = centerYcord function left:touch(event) print( "Hello World!" ) end left:addEventListener("touch",left)

map1.lua

--Variables to set maps X and Y cords to the center of the screen local centerXcord = display.contentCenterX local centerYcord = display.contentCenterY --Displays Map map = display.newImage( "images/map1.png" ) --Centers Map map.x = centerXcord map.y = centerYcord ------------------------------- require("fuctions.controls") ------------------------------- require("fuctions.maincharacter") ------------------------------- -- Variable used to move map along y axis motiony = 0; -- Variable used to move map along x axis motionx = 0; -- Walk Speed speed = 5; -- Move map function movemap (event) map.x = map.x + motionx; map.y = map.y + motiony; end Runtime:addEventListener("enterFrame", movemap) -- When left arrow is touched, move character left function left:touch(event) --Moves the player left motionx = speed; --Targets the left button if touched if ( event.phase == "began" ) then display.getCurrentStage():setFocus( event.target ) --Removes the target if touch has ended or finger has moved off the button elseif ( event.phase == "ended" or event.phase == "moved" ) then display.getCurrentStage():setFocus( nil ) --If button is released sets motion on X axis to 0 motionx = 0; end return true end left:addEventListener("touch",left) -- When right arrow is touched, move character right function right:touch(event) --Moves player to the right motionx = -speed; --Targets the right button if touched if ( event.phase == "began" ) then display.getCurrentStage():setFocus( event.target ) --Removes the target if touch has ended or finger has moved off the button elseif ( event.phase == "ended" or event.phase == "moved" ) then display.getCurrentStage():setFocus( nil ) --If button is released sets motion on X axis to 0 motionx = 0; end return true end right:addEventListener("touch",right) -- When up arrow is touched, move character up function up:touch(event) --Moves player up motiony = speed; --Targets the up button if touched if ( event.phase == "began" ) then display.getCurrentStage():setFocus( event.target ) --Removes the target if touch has ended or finger has moved off the button elseif ( event.phase == "ended" or event.phase == "moved" ) then display.getCurrentStage():setFocus( nil ) --If button is released sets motion on Y axis to 0 motiony = 0; end return true end up:addEventListener("touch",up) -- When down arrow is touched, move character down function down:touch(event) --Moves player down motiony = -speed; --Targets the down button if touched if ( event.phase == "began" ) then display.getCurrentStage():setFocus( event.target ) --Removes the target if touch has ended or finger has moved off the button elseif ( event.phase == "ended" or event.phase == "moved" ) then display.getCurrentStage():setFocus( nil ) --If button is released sets motion on Y axis to 0 motiony = 0; end return true end down:addEventListener("touch",down)

Im sorry if my code seems messy. Im trying to clean it up a little. My question is can i activate 2 fuctions when someone clicks a single button? What im trying to do here is when the player clicks the left button i want it to move the map and print hello world at the same time. I have been stuck on this for a while any help would be great. Currently the map moves no problem but i get no hello world in the command console.

Nevermind i got it.

Nevermind i got it.