So I’m using a keyboard for this project I’m using and I’m trying to make it so you start off at a screen then once tapped it goes to a screen, which is
if currenttouch.state==Began then ??
And then I’m trying to make it so if you tap one of the pictures you need to type something and if its correct something happens, but the thing is how can I make it so you can’t type one right answer for a different picture?
Thanks
A problem with CurrentTouch.state is that it starts as BEGAN, which makes it hard to know when a user actually touches the screen. You should perhaps use the touched function instead. Have a look at the code tab 1_State here…
https://gist.github.com/dermotbalson/6395908
I don’t understand your question about typing right answers for pictures. Can you explain again?
Basically do you know what the “logo quiz” is? Basically that, I will have the logos and you can click them, then if you touch then you can type the answer
Ok, but what is your question?
How do I make it so i can’t just type something right, but it’s for the wrong question, I use
If data==“-” then
And how can I make it so when I click the logos it takes me to the screen?
I tried- if currenttouch.x > 300 and currenttouch.x < 500 and currenttouch.y > 200 and currenttouch.y < 600 then
But it doesn’t work
Maybe something like currentQuestion = 0
and have the if statements for different logos set the currentQuestion value to something else, say from 1-5. Then have a table of all the right answers in the order, and say if answeredQuestion == answers[currentQuestion] then *they got it right* else *they got it wrong*
?
Please give a more clear example of what your problem is, or maybe show us your code. (By maybe I mean do. :P)
Well I just have a really bad prototype of it, and I think I understand it, thanks
@Wallisch_pls I think I know what you’re after, so I put together this to give you an idea of some of the code. Tap on a picture (sprite) and then key the correct answer. The answers are boy, girl, chest, and heart. You can key some wrong answers to see what happens.
displayMode(FULLSCREEN)
function setup()
picture={}
answer={}
correct={}
str1=""
aOffset=0
createTable()
end
function draw()
background(40,40,50)
rectMode(CENTER)
fill(255)
offset=0
for x=1,2 do
for y=1,2 do
offset = offset + 1
if aOffset==offset then
rect(x*200,y*300+200,120,120)
if returnPressed then
if str1==answer[offset] then
correct[offset]=str1.."\
CORRECT"
aOffset=0
else
correct[offset]=str1.."\
Wrong"
end
else
fill(255)
text(str1,x*200,y*300+100)
end
end
if correct[offset]~=nil then
text(correct[offset],x*200,y*300+100)
end
sprite(picture[offset],x*200,y*300+200)
end
end
if keyboardBuffer()~=nil and keyboardBuffer()~="" then
str1=keyboardBuffer()
end
end
function keyboard(k)
if k==RETURN then
returnPressed=true
hideKeyboard()
end
end
function touched(t)
if t.state==BEGAN then
hideKeyboard()
showKeyboard()
returnPressed=false
str1=""
offset=0
aOffset=0
for x=1,2 do
for y=1,2 do
offset = offset + 1
if t.x>x*150 and t.x<x*250 and t.y>y*250+200 and t.y<y*350+200 then
aOffset=offset
if correct[offset]~="" then
correct[offset]=""
end
end
end
end
end
end
function createTable()
table.insert(picture,"Planet Cute:Character Boy")
table.insert(answer,"boy")
table.insert(picture,"Planet Cute:Character Cat Girl")
table.insert(answer,"girl")
table.insert(picture,"Planet Cute:Chest Closed")
table.insert(answer,"chest")
table.insert(picture,"Planet Cute:Heart")
table.insert(answer,"heart")
end