[Resolved] movement by pixel

I am currently testing out Peach Pellen’s great d-pad sprite movement tutorial, and I find it to be pretty fantastic. I understand the concepts, however, I wonder if I can set movement to a pixel amount, rather than a relative “speed” variable. I’ve been reviewing the corona documentation and can’t really find where movement/space is defined. Is this possible with this code? href:</href:> I saw that it was mentioned utilizing the hero.hero.x+1 on each arrow in addition to modifying the touch event would be affective, but I am having trouble implementing it. Does anyone have any tips for me? Any help would be greatly appreciated. Thanks! [import]uid: 135394 topic_id: 25469 reply_id: 325469[/import]

of course I would figure it out 10 seconds after I posted. My new question is, what would an end event look like, which would terminate the movement after 1 touch. Meaning, 1 touch = x pixels. Let me know if that makes sense or if I can provide additional info. Thanks in advance! [import]uid: 135394 topic_id: 25469 reply_id: 102917[/import]

Your link in the first post isn’t correctly inserted :wink:

I misread your question and put something totally wrong together, oops.

I think this is what you are asking for, try running it on its own;
[lua]display.setStatusBar(display.HiddenStatusBar)
local hero = display.newCircle( 160, 240, 30 )

local leftArrow = display.newRect( 10, 10, 80, 40 )
local rightArrow = display.newRect( 230, 10, 80, 40 )

local function pressLeft(event)
hero.x = hero.x - 1
end
leftArrow:addEventListener(“tap”, pressLeft)

local function pressRight(event)
hero.x = hero.x + 1
end
rightArrow:addEventListener(“tap”, pressRight)[/lua]

Tap the buttons at the top, change the 1s for bigger movements, etc.

Let me know if this helps.

Peach :slight_smile: [import]uid: 52491 topic_id: 25469 reply_id: 102926[/import]

@Peach, Thanks so much for your assistance, that is exactly what I was looking for. I’m feeling like a real Dummy McDumbstein over here because I feel I should be able to figure this out without bothering people with more important things to do. Thanks again! [import]uid: 135394 topic_id: 25469 reply_id: 102939[/import]

Haha, not a problem!

It’s not dumb at all, you are new and you aren’t yet used to thinking these things through with clear logic. When you settle in a bit more things like this will come to mind naturally but until then that’s what the forum is for, getting help.

What could be more important than helping a new user, anyway? :slight_smile:

Marking as resolved. [import]uid: 52491 topic_id: 25469 reply_id: 103020[/import]

Perfect and to the point. Love it! Thanks again Peach =) [import]uid: 115955 topic_id: 25469 reply_id: 104751[/import]