Can I implement ball rolling effect using Corona?

Hi,

I’m developing a billiards game. Can I implement ball rolling effect using Corona? In Unity3d, such 3d effect is easy to implement, but I want to know whether I can make such ball roll effect in Corona? Thanks.

Yes you can. Corona SDK is a 2D toolkit, so the approach is, obviously, different.

@_memo

Hi, thanks for your reply, but I think you misunderstand what I said. In the Corona samples, there is a simple pool game demo. But the balls are not rolling like reality, they are just sliding in the table. I want the rolling effect which like a real ball roll on the table. Is there idea to implement the effect?

Hi @datasoftware,

I think this would be possible, but it won’t be easy. You’re basically needing to “map” a 2D texture onto a 2D object, but treat that object as if it were a 3D sphere. If you want to attempt this, you should explore path manipulation operations, i.e. adjusting the corner points of the number/stripe of the billiards ball as the ball moves around.

2.5D — Perspective and Depth

So, this would be a tricky ordeal, but I’ve seen some pretty amazing “magic” accomplished by some Corona developers using 2.5D effects, so I’m optimistic this could be achieved as well.

Take care,

Brent

@Brent

Thanks, I’ll try it.

Personally I wouldn’t attempt 2.5D, which is quite complex. I would simply make a spritesheet with animation frames of a ball rolling, then use good old sprites, only making sure the ball is rotated in the direction it’s moving, so it appears to roll the right way.

Hi @_memo,

I initially considered the sprites concept, until I realized that it might require a vast number of frames. If you consider a sphere with a dot on one point (like the number/circle of a billiards ball), that dot could potentially be positioned on many, many points along several axes of the sphere. For example, if you consider the sphere like the Earth with both “latitude” and “longitude” lines every 30 degrees or so, the dot would need to be positioned at every point where those lines intersected.

I’m not saying it’s impossible, and in fact it probably would be easier than doing 2.5D, but it’s a little more complicated than it initially sounds. :slight_smile:

Brent

@Brent agreed, a large number of frames could be needed if it is to look realistic. Anyway, just thought I’d chip in with an alternative, it wasn’t to bash your suggestion. You’re doing an awesome job helping out everyone around these forums, so thanks for that :slight_smile:

Hi @_memo,

Of course, no offense taken. :slight_smile: Your suggestion is still probably easier to implement than 2.5D path manipulation/rotation. I’m almost considering undertaking the sprite concept as a side project, because it would be awesome to see it done and shared with the community.

Brent

Hi @Brent, and  @_memo
 
There is a easy way to implement ball rolling effect, but not the best. You can download my code from the following link:

http://pan.baidu.com/s/1sjsMXPF

I’m sorry I have to use Baidu Cloud to share the file, so you can see that the language is Chinese. Click the download icon, which is on top right, to download the file.

Yes you can. Corona SDK is a 2D toolkit, so the approach is, obviously, different.

@_memo

Hi, thanks for your reply, but I think you misunderstand what I said. In the Corona samples, there is a simple pool game demo. But the balls are not rolling like reality, they are just sliding in the table. I want the rolling effect which like a real ball roll on the table. Is there idea to implement the effect?

Hi @datasoftware,

I think this would be possible, but it won’t be easy. You’re basically needing to “map” a 2D texture onto a 2D object, but treat that object as if it were a 3D sphere. If you want to attempt this, you should explore path manipulation operations, i.e. adjusting the corner points of the number/stripe of the billiards ball as the ball moves around.

2.5D — Perspective and Depth

So, this would be a tricky ordeal, but I’ve seen some pretty amazing “magic” accomplished by some Corona developers using 2.5D effects, so I’m optimistic this could be achieved as well.

Take care,

Brent

@Brent

Thanks, I’ll try it.

Personally I wouldn’t attempt 2.5D, which is quite complex. I would simply make a spritesheet with animation frames of a ball rolling, then use good old sprites, only making sure the ball is rotated in the direction it’s moving, so it appears to roll the right way.

Hi @_memo,

I initially considered the sprites concept, until I realized that it might require a vast number of frames. If you consider a sphere with a dot on one point (like the number/circle of a billiards ball), that dot could potentially be positioned on many, many points along several axes of the sphere. For example, if you consider the sphere like the Earth with both “latitude” and “longitude” lines every 30 degrees or so, the dot would need to be positioned at every point where those lines intersected.

I’m not saying it’s impossible, and in fact it probably would be easier than doing 2.5D, but it’s a little more complicated than it initially sounds. :slight_smile:

Brent

@Brent agreed, a large number of frames could be needed if it is to look realistic. Anyway, just thought I’d chip in with an alternative, it wasn’t to bash your suggestion. You’re doing an awesome job helping out everyone around these forums, so thanks for that :slight_smile:

Hi @_memo,

Of course, no offense taken. :slight_smile: Your suggestion is still probably easier to implement than 2.5D path manipulation/rotation. I’m almost considering undertaking the sprite concept as a side project, because it would be awesome to see it done and shared with the community.

Brent

Hi @Brent, and  @_memo
 
There is a easy way to implement ball rolling effect, but not the best. You can download my code from the following link:

http://pan.baidu.com/s/1sjsMXPF

I’m sorry I have to use Baidu Cloud to share the file, so you can see that the language is Chinese. Click the download icon, which is on top right, to download the file.