Hello,
I would like to know if it's possible to slice objects (ie. Fruit Ninja) into two separate objects. If it is, how would you suggest to accomplish this?
Thanks,
Label: corona android iphone ipad building error inmobi problem display screen View image tableView failed object physics touch button game lua config event listener |
Hello,
I would like to know if it's possible to slice objects (ie. Fruit Ninja) into two separate objects. If it is, how would you suggest to accomplish this?
Thanks,
This can't be done automatically as Corona doesn't give you control over the texture vertices. You need to create 2 new objects and maybe work with a mask on each object to cover the cut off area.
To expand on what Mike said (create 2 new objects), I'm pretty sure that's what Fruit Ninja does.
If you play around with it you'll see the fruits are always cut in half -- it's especially easy to see on the bananas. Even if you slice them lengthwise it shows up as two pieces cut the short way.
Plus, there's a little "splash" (explosion) that happens when you slice and that helps camouflage switching from one object to two objects.
So to create that effect, code your slice routine and when you get a hit, use orangeHalf1 = display.newImage() and orangeHalf2 = display.newImage() to create the two halves, set their X/Y coords based on orange.x and orange.y,. and then use orange:removeSelf() to get rid of the the intact fruit.
Assuming you make those objects physics objects, you'll probably want to apply a random force to each so they don't just drop straight down. Look at the physics API, things like applyAngularImpulse( ), etc.
Plus, you'll probably want to use movieclips or sprites so the fruit can "tumble" as it falls.
Lots of cool things to dig into. I wish I had more time! :)
Jay
That sounds easy to do for an expert:-)
how about another iphone game "iSlash"
http://www.youtube.com/watch?v=FcwZ_qRWBDg
yuewah, what MikeHart said would also apply to the game in the video you linked to, so unfortunately not possible at this time.
J.A. your suggestions about mock ups are great; reading it makes me want to go and have a go at remaking Sushi Slice as a real slice game rather than, well, what it is right now ;)
Peach
Peach, imho it is possible already with a little bit of Math and clever use of masks.
MikeHart, perhaps something I should explore more - although honestly I can't imagine a way to create it realistically at this time although I suppose anything is possible if willing to devote enough time to experimenting with code.
Not enough hours in the day!