Page 1 of 1

help with shapes based game

Posted: Mon Jan 30, 2012 4:31 pm
by d.m.holdawayGA2553
Hello,

i am working on a game for my iPad that my young son can use.

i just need a little help with the logic, at the moment i can drag the shapes around the screen and i can drag them into the holes

but the issue i am having is that i can put circles into a square shaped box

what would be the best way to test that the right shape is going into the correct hole?

should i just use a if statement

if shape is wrong then display error else fill hole with shape.

any advice is welcome, i have worked though the online Game Academy lessons so if there is a bit that you think is relevant within the webinars please say and i will go back and re watch them

Re: help with shapes based game

Posted: Mon Jan 30, 2012 5:09 pm
by sturgis
Hmm assuming you are creating the holes and shapes yourself (programatically) you can simply check whats what. Either name your objects (a hole named "square 1" and an object named "square 1") then you just have to compare the names of the 2 objects. if the short name of the object being dragged matches the short name of the object its being dropped on then its correct, otherwise say so and move the object out of the box. The same could be done with custom properties of each object. Say a listing on your square hole, which objects are allowed to be dropped there.

If asking about the actual mechanics and code of such a solution rather than just a pointer in a direction post again (possibly with your current drag code so answers can be more tailored to your current methods)