Share Your Code

Match The Letter

Posted by johnpolacek, Posted on March 10, 2011, Last updated October 18, 2011

Match The Letter is a simple picture game for helping kids learn their letters. I posted the source to github. I built it both for my son to play with and to get more familiar with Corona, so any feedback is appreciated.

https://github.com/johnpolacek/Match-The-Letter-Game

The app is available for download on the iTunes App Store and Google Marketplace. For more info, go to http://johnpolacek.com/matchtheletter


Replies

Jalmood
User offline. Last seen 3 hours 27 min ago. Offline
Joined: 13 Mar 2011

Thank you for sharing your useful App.

I try to install in my Galaxy Tab Android 2.2 .. but application can't start and only blank screen.

Are you using native API for iOS?

Best Regards,

Abdullah

johnpolacek
User offline. Last seen 1 year 46 weeks ago. Offline
Joined: 8 Jan 2011

Did you download the app from the android market, or do a corona build from the source and install that?

I'm not sure if I understand your second question. This app is built with the Corona SDK, not Objective-C, although the ultimate result is a native app.

Jalmood
User offline. Last seen 3 hours 27 min ago. Offline
Joined: 13 Mar 2011

Sorry I don't know that your app in Android market .. I download it from there and its working fine.

When I compile your source and install in Android not working .. what should I change in your code to work with Android?

Thank you.

Abdullah

johnpolacek
User offline. Last seen 1 year 46 weeks ago. Offline
Joined: 8 Jan 2011

I am seeing the same thing. Since publishing to the Android market, I made a few changes to do a Universal Binary for iOS, but I don't know why those would effect the android build. It runs just fine in the android emulator, but not on the actual device.

I also did the build with a previous version of the SDK, so perhaps the upgrade might have something to do with it.

KeepTrying
User offline. Last seen 5 weeks 5 days ago. Offline
Joined: 2 Jan 2011

First of all many thanks John ! that easing package from Sparrow is very usefull - I have the same issue like the others, your code work outstanding on iOS 4.3 8F190 running on iPhone 3GS but when i deploy to Android 2.2 running on LG Optimus One P500h armv6 600Mhz 512MB i got a blank screen ! My version Corona SDK 2011.268 Mac OSX > What version you used to do that sample ? Great ArtWork on deviantart !

johnpolacek
User offline. Last seen 1 year 46 weeks ago. Offline
Joined: 8 Jan 2011

I posted about this in the bugs forum.
http://developer.anscamobile.com/forum/2011/03/19/app-works-android-simulator-not-device

For the working android app in the marketplace, I used the previous sdk release (I forget the build number). Is there somewhere we can get old sdk builds?

kelvinmfaber
User offline. Last seen 2 years 15 weeks ago. Offline
Joined: 2 Apr 2011

First, thanks for sharing this.

I am newb and am trying create my first app and am using this a app as starting point.

I have gone through the code and have been able follow most of it. Changing a few things here and there to meet my goals but have run into a wall with the following.

Instead of showing random letters with the correct letter I would like to have a defined set for each item. I am thinking I can then expand the answers from a single letter to a word or short text string.

I was able to add the correct answer and a wrongs answers in the content as follows...

1
2
3
4
5
6
        {
                id = "ambulance",
                word = "ambulance",
                ca = "e",
                wa = "a", "b", "c", "d"
        },

I was then able to assign the correct answer by changing

-- make letter button for correct letter (line 202)

1
2
3
4
        local letter = content[questionNumber].ca
        table.insert(letterButtons, factory.newLetterButton(letter, isLowerCase, buttonColors[1]))
        correctButton = letterButtons[1].graphics
        local buttonWidth = correctButton.width

Here is where I get stuck. I have tried several different ways of getting the wrong answer list (wa) from the content file into alphabit list

in factory.lua

1
local alphabet = { content[questionNumber].wa }

Moved local alphabet from factory.lua to main.lua ( line 180 after local questionNumber)

1
local alphabet = { content[questionNumber].wa }

or
1
local alphabet = { content[questionNumber].wa }

Any help or suggestions will be greatly appreciated. TIA

kelvinmfaber
User offline. Last seen 2 years 15 weeks ago. Offline
Joined: 2 Apr 2011

Hello,

I figured out a way to get the wrong answers to be read from the content.lua file. Not sure this is the best way but it seems to work.

Change content.lua to

1
2
3
4
5
6
7
8
9
10
        {
                id = "ambulance",
                word = "ambulance",
                ca = "e",
                wa1 = "z",
                wa2 = "b",
                wa3 = "c",
                wa4 = "d",
                wa5 = "y"
        },

Removed

1
local alphabet = {"a", ... "z"}

from factory.lua

Added

1
factory.alphabet = {content[questionNumber].wa1, content[questionNumber].wa2, content[questionNumber].wa3, content[questionNumber].wa4, content[questionNumber].wa5 }

to main.lua, following local questionNumber

As I stated this is probably not the best way to do this, any suggestions/recomendations will be greatly appreciated.

I am now going to start looking at making the buttons simple words instead of letters.

TIA

johnpolacek
User offline. Last seen 1 year 46 weeks ago. Offline
Joined: 8 Jan 2011

Not sure if I'm following what you are trying to do, but if you want to make words, you can use the code from the showWord() function, which has a loop that makes a letter graphic for each character in whatever word(s) you want to make.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
wordGraphic = display.newGroup()
local wordColor = factory.getRandomColors(1)[1]
local animationDelay = 500
for i=1,string.len(word) do
    local char = word:sub(i,i)
    if char == " " then
        -- space
    else
        local char = factory.newLetterButton(char,isLowerCase,wordColor).graphics
        wordGraphic:insert(char)
        char.x = (char.width * .72) * (i-1)
        local charDelay = (i-1) * animationDelay
        timer.performWithDelay(charDelay, playLetterSound)
        transition.from(char, {time = 400, delay = charDelay, y=centerY+char.height, transition=easing.easeOutElastic})
    end
kelvinmfaber
User offline. Last seen 2 years 15 weeks ago. Offline
Joined: 2 Apr 2011

Thanks John for the reply.

I have been working and have not had chance to get back to this, sorry for the delay.

What I am trying to do is make it so the answers are words or a phrase instead of a single letter. I have been able to add the words/phrases but am struggling to position and scale the answers buttons.

I like the the way you have made it so the answers are in a random order and with a random graphic.

I am struggling with getting the answer background graphics to scale to the largest answer. I may need to settle on a predetermined layout and size and make the answers fit.

Also because the answers will now take more horizontal space I cannot display 4, 5 answers in a single line/row. Here I am trying to figure out how to display the answers in 2 lines/rows when the user select a higher difficulty level.

Here is a crude layout

Difficulty 1,2,3   centered horizontally across bottom
              ----------  ----------  ----------
             | Answer 1 || Answer 2 || Answer 3 |
              ----------  ----------  ----------

The above can be done with you're existing code.

Difficulty 4  centered horizontally across bottom, 2 lines/rows of 2
                    ----------  ----------
                   | Answer 3 || Answer 4 |
                    ----------  ----------
                   | Answer 1 || Answer 2 |
                    ----------  ----------
Difficulty level 5 centered horizontally across bottom, 2 lines/rows of 3
              ----------  ----------  ----------
             | Answer 4 || Answer 5 || Answer 6 |
              ----------  ----------  ----------
             | Answer 1 || Answer 2 || Answer 3 |
              ----------  ----------  ----------

I am attempting to place an "If then" statement in the
-- position letter buttons and add touch event listener
section but have not had any success as of yet.

Any advise or pointers will be greatly appreciated.

GP Animations
User offline. Last seen 1 hour 20 min ago. Offline
Joined: 19 Oct 2011

.