Where to start with empty screen to register touch event to draw a line that follows path?

First I am not only new to the Corona SDK, but to Lua as well.

I have been running through the tutorials and samples, to learn both the SDK and Lua. There is one thing I would like to play with that I cannot find any really focused on it. That would be I want to draw a line that follows the users finger right in main and without any thing else drawn on the screen yet.

I read about touch events, and drawing polylines, and looked at the Martian game example that draws a line from a ship following the finger to where they stop. However I cannot see where to register my touch event when there is nothing on the screen yet. I do not want to draw a polyline because I don’t know where the touch is going to start. I didn’t see any built in “display” object that would allow me to register a touch event against the display itself.

So this left me confused, do I have to place a background image just so I can have something to register a touch event against, this seemed odd. Also do I or can I just draw a filled rect covering the whole screen and then register the touch event against that and then draw the polyline on top the image or rect sampling the touch location until the touch event is done?

Anyway, any help would be appreciated, kind regards. [import]uid: 43562 topic_id: 7735 reply_id: 307735[/import]

I have the same question as well but for a slightly different reason. I am writing games that are audio only and have no need for any on-screen objects. I just want to be able to track touch and shake events. I can’t find a way to do this either. [import]uid: 44633 topic_id: 7735 reply_id: 27518[/import]

liamerven: read the docs!
http://developer.anscamobile.com/reference/index/eventisshake [import]uid: 6645 topic_id: 7735 reply_id: 27583[/import]

@jmp909, your “Read the docs!” comment is not helpful at all and it doesn’t address the issue of attaching events without having anything drawn on the screen.

event.isShake appears to require an “EVENT” which has to be registered against something. The whole issue is not that we don’t understand events, it is that they require to be registered against something and therefore when you have NOTHING on the screen what do you register them against.

Trust me, I have done nothing but RTFM, and I cannot find anything I wouldn’t have asked my question if I haven’t done my due diligence. If you cannot be civil in your comments in a forum please keep them to yourself as comments like yours are not helpful when you are “yelling” at someone to read the manual. Then on top of that when your link to the “manual” doesn’t even answer the question that is asked you are just making yourself look bad.

Forums are about helping. [import]uid: 43562 topic_id: 7735 reply_id: 27605[/import]

i admit the docs could be better structured, but anyway the accelerometer events are listed under the Runtime event listener section

http://developer.anscamobile.com/content/events-and-listeners#Runtime_Events

and given as an example in the resources
http://developer.anscamobile.com/content/accelerometer-1

which is also included in the samples in the Corona download
[lua]Runtime:addEventListener (“accelerometer”, onAccelerate);[/lua]

this should get you started [import]uid: 6645 topic_id: 7735 reply_id: 27612[/import]

I read that entire page on events and listeners several times before asking my question. I read the Runtime events section over and over, and it doesn’t list “touch” as a Runtime event. It only list 6 events that are runtime events that cannot be assigned to a Target. The events I care about is the Touch events and how and what to register them to if you have no “display objects” on the screen. There doesn’t seem to be any high level display object for the screen itself to register against.

I also asked that if you cannot do what I want is the “work around” for this to just create a screen size filled rect that I can register these events.

So either the docs are horrible when they appear to be well written, and any event can be a Runtime event or it is well written and this concept that I am asking about is just missing from the SDK, in which case my workaround most will work, but sucks to do it, then my request would become more of a feature request.

For the record I think the docs are good, and as with many they don’t always try to answer all the explicit things you can’t do, although this seems like an obvious thing you would want to do and may need a note in the doc explaining it more clearly.
[import]uid: 43562 topic_id: 7735 reply_id: 27617[/import]

@rsfoley - try something like this

[code]
display.setStatusBar( display.HiddenStatusBar )

local function touched( event )

if event.phase == “began” or event.phase == “moved” then

local dot = display.newRect( event.x, event.y, 6, 6 )

end

end

Runtime:addEventListener(“touch”, touched)
[/code] [import]uid: 8366 topic_id: 7735 reply_id: 27634[/import]

Hi, if you go to the first link in my last post there is a line of code above

[lua]Runtime:addEventListener( “touch”, myObject ) [/lua]

Note that since there is no function specified there you need

[lua]function myObject:touch[/lua]
When using it that way

However since you have no object just supply a function. This is explained in the table listeners section [import]uid: 6645 topic_id: 7735 reply_id: 27636[/import]

@evs Thank you, that simple example answers all the questions and more. [import]uid: 43562 topic_id: 7735 reply_id: 27674[/import]

An old post … but thanks evs … solved my problem too! Peter

An old post … but thanks evs … solved my problem too! Peter