Collision and Cheat codes

So im pretty new here but i have manage to make a pretty nice game so far. But there is some question that i want to ask you guys.

  1. I dont understand collisions and i cant find any good tutorial. So can somebody explain that for me or send a link to a good tutorial. I want this: When my character touches(collects) a coin in the game the coin will disapear, a sound will be played and some score will be added.

  2. And then i want a “Cheat code” option. Where you put some text into a textbox and if you put right code you will unlock something(i will have different codes for different things).

So, how do i make this things? Any tips, tutorial or something like that?

//Philip :slight_smile: [import]uid: 119384 topic_id: 22207 reply_id: 322207[/import]

For the collision stuff see this tutorial mini-set; http://techority.com/2011/06/19/corona-for-newbies-part-4-physics/

For the cheat code, you would use a native.newTextField and then on submission see if the text matched whatever codes you were using and if so turn on the cheat. [import]uid: 52491 topic_id: 22207 reply_id: 88376[/import]

Thanks a lot Peach :)! Now i understand collisions. But i still doesnt understand that cheatcode thing. I understand what you mean but i dont know how to make it:/

Any good tutorial or sample code for that?

//Philip :slight_smile: [import]uid: 119384 topic_id: 22207 reply_id: 88448[/import]

cheat codes…
[lua]–forward declaration
local cheatField
local cheatCode = “goDaddy12”
local function listener(event)
if ( “began” == event.phase ) then
– This is the “keyboard has appeared” event

elseif ( “ended” == event.phase ) then
– This event is called when the user stops editing a field:
– for example, when they touch a different field or keyboard focus goes away
if cheatField.text == cheatCode then
–Cheat functions etc
else
–display incorrect dialogue etc
end

elseif ( “submitted” == event.phase ) then
– This event occurs when the user presses the “return” key
– (if available) on the onscreen keyboard

– Hide keyboard
native.setKeyboardFocus( nil )
end

end
–we make a native.newTextField for user input
cheatField = native.newTextField(10,100,300,25)
–make the ‘listener’ function the listener for the text field
cheatField:addEventListener( ‘userInput’, listener) [import]uid: 24641 topic_id: 22207 reply_id: 88450[/import]

Good stuff!

By the way @mdcapps I saw you put up some code in sample code last year and actually gave me a shoutout; I hadn’t seen it previously and wanted to say thanks :slight_smile: [import]uid: 52491 topic_id: 22207 reply_id: 88578[/import]

that’s ok Peach – you really helped me when I was starting out [import]uid: 24641 topic_id: 22207 reply_id: 88623[/import]