Hi, I’m new to codea and I’m trying to make a small game from an idea I had.
I saw the Multi-touch sample but I don’t really know how to use it in this case.
Basically I want to have like a line of a fixed length joining two points, if you touch both of the ends you can move and rotate it. I want to know how to get the x and y coordinates of two positions at the same time, so I can use one of those for the position and the other for the rotation angle.
If I’m not clear enough I’m sorry and I’ll try to explain myself better.
Thanks a lot for your help!
Maybe this will give you an idea. Put 2 fingers on the screen and move them around.
supportedOrientations(PORTRAIT_ANY)
displayMode(FULLSCREEN)
function setup()
tab={} -- table of touches
end
function draw()
background(40,40,50)
fill(255)
for z=1,#tab do
str=string.format("x = %d y = %d",tab[z].x,tab[z].y)
text(str,WIDTH/2,1000-50*z) -- display x,y values
if z==2 then -- only do this for 2 touches
stroke(255)
strokeWidth(4)
ellipse(tab[1].x,tab[1].y,20)
ellipse(tab[2].x,tab[2].y,20)
line(tab[1].x,tab[1].y,tab[2].x,tab[2].y)
end
end
end
function touched(t)
if t.state==BEGAN then
table.insert(tab,vec3(t.x,t.y,t.id)) -- put x,y,id in table
elseif t.state==MOVING then
for a,b in pairs(tab) do
if t.id==b.z then -- id matches entry in table
tab[a]=vec3(t.x,t.y,t.id) -- update x,y,id in table
return
end
end
elseif t.state==ENDED then
for a,b in pairs(tab) do
if t.id==b.z then -- id matches entry in table
table.remove(tab,a) -- remove entry from table
end
end
end
end
.@pmdmaster Correct me if I’m wrong but didn’t someone already make a game like that.
Yeah, it was touchline over at http://touchlinegame.com/
@beu5mi dave1707 is giving pmdmaster an example of multitouch. The example in this case doesnt reflect the idea in @pmdmaster’s head
@beu5mi Well, that is similar to what I had in mind. We’re making a project for a class with Codea, and this was only to try to understand better how it works and what I can do with it.
Since I don’t have an iPad, I only get access to one during class so I don’t have a lot of time to try other stuff, but I want to understand how to do some things I need for our project so meanwhile I’ll look in this forum and other websites, and ask here if I don’t find something.
@dave1707 Thanks for your help, after I am done with the other proyect I’ll try it. I still want to make this game just for fun, when I have the time for it.