Rotating a specific portion of an object. Texture-filled display objects.

I want to rotate a specific part of an object without having to overlay a separate display-object; what is the most efficient way to accomplish this?
An example of what I’m trying to accomplish would be that similar to how a railroad car changes direction by way of a platform that rotates&aligns the car to a different portion of track.

I would like the platform to behave in the following manner: Say the train is on the platform facing East and it needs to head North, the user would (by way of touch) rotate the platform and once it has rotated past, say, 45º it would ‘snap’ to the North facing position.

Is it possible to have a curved line or rectangle that is texture-filled?
I have a display object with a look/texture I want, but I need it to be curved… can I draw a curve and somehow overlay the texture to follow the path of the curved object?

-Saer [import]uid: 148623 topic_id: 34431 reply_id: 334431[/import]

  1. Not really. Your platform would have to be a separate image. You can then use the .rotation attribute to control its rotation and figure out what the current rotation is:

platform.rotation = 45

It will be easy enough to check in you touch event if the angle is < 45 or greater than 315, then set it to 0. As for #2, Corona doesn’t have texture mapping like a 3D engine would have. You load in a rectangular image. If you’re using physics, you can apply custom shapes to fit the curve somewhat.

[import]uid: 199310 topic_id: 34431 reply_id: 136846[/import]

  1. Not really. Your platform would have to be a separate image. You can then use the .rotation attribute to control its rotation and figure out what the current rotation is:

platform.rotation = 45

It will be easy enough to check in you touch event if the angle is < 45 or greater than 315, then set it to 0. As for #2, Corona doesn’t have texture mapping like a 3D engine would have. You load in a rectangular image. If you’re using physics, you can apply custom shapes to fit the curve somewhat.

[import]uid: 199310 topic_id: 34431 reply_id: 136846[/import]

-Sorry for the delayed response-

Thanks Rob!
I have got it working exactly how I want! :slight_smile:

-Saer [import]uid: 148623 topic_id: 34431 reply_id: 137942[/import]

-Sorry for the delayed response-

Thanks Rob!
I have got it working exactly how I want! :slight_smile:

-Saer [import]uid: 148623 topic_id: 34431 reply_id: 137942[/import]

Hey Rob,

One last question: in keeping with the train example, how would I move the train along the track?
Would it have something to do with a bezier curve and coding the train follow a predetermined path?

I have some example code that demonstrates how to draw a curve and move an object along that curve, but I am wondering how to make a path and have my object move along the path via the user dragging the object.

I would normally just code it to move along the x,y axis of an object, but in this case the majority of my graphical elements are merged images, and not individual assets.

-Saer

[import]uid: 148623 topic_id: 34431 reply_id: 139613[/import]

I’m not sure of an easy way to accomplish that. The curve path idea may be the best.
[import]uid: 199310 topic_id: 34431 reply_id: 139658[/import]

Hi Saer,

There is a good example on how to follow a curve in the examples that come with level director (www.retrofitproductions.com)
You can create your own curves and it will export the code for you, pretty cool and may help you.
[import]uid: 158620 topic_id: 34431 reply_id: 139681[/import]

Hey Rob,

One last question: in keeping with the train example, how would I move the train along the track?
Would it have something to do with a bezier curve and coding the train follow a predetermined path?

I have some example code that demonstrates how to draw a curve and move an object along that curve, but I am wondering how to make a path and have my object move along the path via the user dragging the object.

I would normally just code it to move along the x,y axis of an object, but in this case the majority of my graphical elements are merged images, and not individual assets.

-Saer

[import]uid: 148623 topic_id: 34431 reply_id: 139613[/import]

I’m not sure of an easy way to accomplish that. The curve path idea may be the best.
[import]uid: 199310 topic_id: 34431 reply_id: 139658[/import]

Hi Saer,

There is a good example on how to follow a curve in the examples that come with level director (www.retrofitproductions.com)
You can create your own curves and it will export the code for you, pretty cool and may help you.
[import]uid: 158620 topic_id: 34431 reply_id: 139681[/import]