I have a problem xD

Hello everyone I ve seen that here is full of capable people so I want to ask a question to you

In few words I have 2 images

local omino = display.newImage("omino.png") omino:setReferencePoint(display.BottomLeftReferencePoint) omino.x = 66 omino.y = 249 local omino2 = display.newImage("omino2.png") omino2:setReferencePoint(display.BottomLeftReferencePoint) omino2.x = 68 omino2.y = 139

The “omino2” run alone and i used an enterframe function :

function corri(self, event) self.x = self.x + 3 end omino2.enterFrame = corri Runtime:addEventListener("enterFrame", omino2)

The “omino” have to run and overtake “omino2” after each “touch” of the player. So  I need that the for each Touch the “omino2” must move back 12px from the position that he has in that moment (the moment I touch the screen).

I tried to make somethinng like this:

function avanza(event) if event.phase == "began" then transition.to(omino2,{ time = 50 ,x = self.x - 12} ) end end tasto:addEventListener("touch" , avanza)

But the System doesn’t recognize the "self.x - 12 " command. What I have to do??

( Sorry Again For My Bad English)

 

You don’t have “self” specified in the above function. You want to modify if to (self, event), and then update the listener to be a table listener:

http://docs.coronalabs.com/api/event/touch/index.html#table-listener-1

Sorry I m new in coding. Can you make me an example to solve this Problem?

Here is the example from the documentation link I provided:

local object = display.newImage( "ball.png" ) object.id = "ball object" local function onObjectTouch( self, event ) if event.phase == "began" then print( "Touch event began on: " .. self.id ) end return true end object.touch = onObjectTouch object:addEventListener( "touch", object )

If you’re new to coding with high level development languages, I’d strongly suggest going through the guides and tutorials to learn how to be successful with Corona SDK. Starting at the beginning is best, but here is the guide specific to touch/interactivity:

http://docs.coronalabs.com/guide/events/detectEvents/index.html

You don’t have “self” specified in the above function. You want to modify if to (self, event), and then update the listener to be a table listener:

http://docs.coronalabs.com/api/event/touch/index.html#table-listener-1

Sorry I m new in coding. Can you make me an example to solve this Problem?

Here is the example from the documentation link I provided:

local object = display.newImage( "ball.png" ) object.id = "ball object" local function onObjectTouch( self, event ) if event.phase == "began" then print( "Touch event began on: " .. self.id ) end return true end object.touch = onObjectTouch object:addEventListener( "touch", object )

If you’re new to coding with high level development languages, I’d strongly suggest going through the guides and tutorials to learn how to be successful with Corona SDK. Starting at the beginning is best, but here is the guide specific to touch/interactivity:

http://docs.coronalabs.com/guide/events/detectEvents/index.html