Jump to content

Transparency problem


amateus_com
 Share

Recommended Posts

Hello everyone,

 

I have been struggling with a problem that I can't seem to solve. Don't know if it's lack of pixi knowledge, concept problem or lack of a good night sleep (probably a bit of all).

 

I'm working on a simple game concept, similar to an old game called Jumpin Jack. Consider this image:

 

CU1Iqr9WsAE4OX0.jpg

 

This scene is composed by 2 sprite types: the red lines (platform) and a white sprite (the hole) moving along the lines (on a top layer). So, each time I want to create a hole, I simple add a new sprite of type 2 and move him accordingly.

 

Problem is, behind this first top layer, I can have background images or other objects, etc, so the white holes that worked so well on a white background now looks really bad, because in fact the white block appears on top of everything.

 

I consider using tilesprite, only moving the red line (that already has a transparent hole) when the hole is in that line, but gave problems because I can have two holes on the same line (moving on different directions).

I consider using a transparent sprite for the hole, but of course the transparent white shows.... the red line behind..

I consider using a mask, using the sprite but that didn't work either.

 

So, what I really need is a way to say: on this specific rectangle, sprite line is transparent (creating the hole and seeing the background), and I update that area every frame, thus moving the hole.

 

Any ideas?

 

Thanks,

AM

Link to comment
Share on other sites

Or just change the size of each line, the maths is pretty simple to remove an arbitrary segment.

 

As Ivan said, your collision detection will be easier if the size of your platforms really are the size of the platforms (i.e. there is a real hole in the object representing the platform, or, more accurately, there are 2 platforms with a gap)

Link to comment
Share on other sites

Hi,

 

Thank you for your idea.

 

check this video: https://www.youtube.com/watch?v=Ai-ocyGR_LQ.

 

The holes move along the lines and from bottom line to the last line (and in inverse to be precise), so the segments solution would only work if the holes were stationary. Or I didn't understand your idea at all :)

 

AM

 

 

Container for each line contains a set of segments. If segments number if changed (two holes or so) , spawn or delete some sprites.

 

UPD. you need that thing anyway, if you want to use box2d or something like that

Link to comment
Share on other sites

Hi,

 

As said above, the solution would work if the holes were stationary. Nevertheless I will explore this approach to see where it gets

 

Thanks :)

 

 

 

Or just change the size of each line, the maths is pretty simple to remove an arbitrary segment.

 

As Ivan said, your collision detection will be easier if the size of your platforms really are the size of the platforms (i.e. there is a real hole in the object representing the platform, or, more accurately, there are 2 platforms with a gap)

Link to comment
Share on other sites

Hi,

 

As said above, the solution would work if the holes were stationary. I will work this approach anyway to see where it gets

 

Thanks :)

 

In your update code just change the size of the platforms.

 

I'd track the size of the holes and have some code that 'removes' that segment from my platforms, then update the position of the gap and run the code that does the subtract. This way the gaps can be anywhere and of any size.

 

Job done I think.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...