Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (710)
Games in Android Showcase (212)
games submitted by our members
Games in WIP (784)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Only show overlapping portion of shape (LibGDX)  (Read 970 times)
0 Members and 1 Guest are viewing this topic.
Offline devinjv

Junior Newbie

Exp: 4-6 months

« Posted 2014-04-30 00:16:50 »

So I'm stuck again Hopefully someone can help

I'm working on my first app, a 2d side-scroller. It's a bat in a cave and he will shoot out a Circle shaped sonar. I want this circle to be generally invisible and only show the parts of it that are overlapping my triangular "Polygon" objects (cave spikes). I looked through the LibGDX documentation and had trouble finding a way of locating coordinates of the point where shapes are overlapping. Any quick tips would be awesome to get me in the right direction.
Offline UprightPath
« Reply #1 - Posted 2014-04-30 02:10:22 »

You could always do a mask. Basically, you invert the screen-- Locations with triangles become gaps and gaps gain triangles-- then you set up layers such that (From near camera to furtherest): Player/UI (Very top/always visible objects), Mask (As described), the Sonar, the spikes (If you have a reason to draw them at all, I mean.)

This is probably the easiest method. And I use that term lightly. Alternately, you can try something involving polygon clipping (But a circle can be a PITA because it's either not a real polygon or it's a polygon with infinite vertices-- Or just a bunch):

Offline devinjv

Junior Newbie

Exp: 4-6 months

« Reply #2 - Posted 2014-04-30 04:56:02 »

Thanks for your reply! The way you described masking sounds like exactly what I'm going for. Just having some trouble finding more information on the topic. Will keep looking.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ikovrigin

Senior Newbie

« Reply #3 - Posted 2014-04-30 05:05:49 »

This can be done using shader. Just use center and R of sonar as a parameter. This is if you want use precise calculation. In other hand if it is your first game just simplify this problem.
1. You can calculate distance for each vertex and interpolate values inside triangle.
2. You can draw cave spike if it's center inside a sonar circle.
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

numerical (58 views)
2017-02-21 07:32:16

numerical (57 views)
2017-02-21 07:31:46

theagentd (162 views)
2017-02-18 13:42:33

theagentd (165 views)
2017-02-18 13:35:16

h.pernpeintner (1328 views)
2017-01-24 22:39:11

h.pernpeintner (1316 views)
2017-01-24 22:38:32

Galdo (1876 views)
2017-01-12 13:44:09

Archive (1968 views)
2017-01-02 05:31:41

0AndrewShepherd0 (2507 views)
2016-12-16 03:58:39

0AndrewShepherd0 (2308 views)
2016-12-15 21:50:57
List of Learning Resources
by elect
2016-09-09 09:47:55

List of Learning Resources
by elect
2016-09-08 09:47:20

List of Learning Resources
by elect
2016-09-08 09:46:51

List of Learning Resources
by elect
2016-09-08 09:46:27

List of Learning Resources
by elect
2016-09-08 09:45:41

List of Learning Resources
by elect
2016-09-08 08:39:20

List of Learning Resources
by elect
2016-09-08 08:38:19

Rendering resources
by Roquen
2016-08-08 05:55:21 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!