Bezier segment manipulation using Corona SDK. This is a sample of how to manipulate a cubic bezier segment. Touch the screen to draw the four points (anchor1,handle1,handle2,anchor2) then manipulate the curve.
I cleaned up the code as much as I could. It is not optimized. Feel free to make changes, amplifications and updates and share with the rest of us.
hi im using the latest version of corona sdk, i have downloaded the code but im getting a blank black screen when i try to open,
[import]uid: 10239 topic_id: 4409 reply_id: 13778[/import]
This is excellent! (code and timing)
I’ve got a character in an animation flying a kite (with accelerometer) now I’ve got the kiteString too.
Now, if we can just talk Jonathan Beebe into making an OpenSource “Cut the Rope” clone :^)
Andy [import]uid: 5339 topic_id: 4409 reply_id: 13787[/import]
OK. Sorry but this is pretty mind blowing to me. Are you telling me that I can somehow manipulate your code to create curves with body and have say a ball slide down that awesome bezier curve? [import]uid: 8192 topic_id: 4409 reply_id: 14639[/import]
I’m really impressed by your bezier code, but I’d like to know how you got the tank to smoothly follow the curve. Obviously, you’re not using the physics engine, but I’m having a little trouble getting the same effect.
Set the tolerance to an acceptable level
Get the points to the curve
Walk the points and as you walk them get the angle between the points
move the object along the points and rotate it given the angle
C [import]uid: 24 topic_id: 4409 reply_id: 15070[/import]
Yep, I got that much, however the flip between, say, 5 degrees and 355 degrees causes the tank to spin a full circle on the spot. I was wondering how you got round this? I did myself, but was wondering about other approaches…
Matt [import]uid: 8271 topic_id: 4409 reply_id: 15079[/import]
My bad - I think I assumed certain things. The problem I referred to comes from transition.to (which I used for smooth animation from one angle to the next) tweening between 355 and 5 degrees through the larger range around the circle’s 360, not directly through the 360|0 border…
That, of course, is to simply check the difference and add/subtract 360 where appropriate.
m [import]uid: 8271 topic_id: 4409 reply_id: 15089[/import]