13 Replies - 2259 Views - Last Post: 19 February 2012 - 11:31 PM Rate Topic: -----

#1 jurdendurden  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 39
  • Joined: 01-November 07

Transparency Key

Posted 09 February 2012 - 06:34 PM

I have set my transparency key for my sprites and it works, with one exception. The background on my sprites is now showing completely through the form, even through the map object behind it! How can I prevent this?
Is This A Good Question/Topic? 0
  • +

Replies To: Transparency Key

#2 ricardosms  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 73
  • View blog
  • Posts: 301
  • Joined: 02-April 10

Re: Transparency Key

Posted 09 February 2012 - 07:06 PM

Check object.parent, if your form is the parent object it will show the form under it, if it's parent is another container or object it will be shown. You can assign the parent property.
Was This Post Helpful? 0
  • +
  • -

#3 jurdendurden  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 39
  • Joined: 01-November 07

Re: Transparency Key

Posted 09 February 2012 - 07:55 PM

I have no other windows forms objects on this form to make parents... so right now the parent is the form, which is why it's going straight through to whatever is in the background.. Unless I'm misinterpreting what you are saying.. That won't work.
Was This Post Helpful? 0
  • +
  • -

#4 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,499
  • Joined: 16-March 11

Re: Transparency Key

Posted 10 February 2012 - 12:12 AM

Your problem is the picture boxes, I never figured it out myself, but I came to learn that using the GDI Classes is much more efficient, and suits the task much better. You'll be better off drawing transparent images that way, and it's not much more complex if at all complex.

GDI Tut

This is the link that I used when I was learning, but most the learning comes from experimenting with it.

Btw there is also the option of using a second form to overlay the original form, you could try setting the picture box on that form, and the transparency key to that, because the picture box is only transparent to it's parent form. If that makes sense.

This post has been edited by trevster344: 10 February 2012 - 12:36 AM

Was This Post Helpful? 0
  • +
  • -

#5 jurdendurden  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 39
  • Joined: 01-November 07

Re: Transparency Key

Posted 10 February 2012 - 01:05 AM

View Posttrevster344, on 10 February 2012 - 12:12 AM, said:

Your problem is the picture boxes, I never figured it out myself, but I came to learn that using the GDI Classes is much more efficient, and suits the task much better. You'll be better off drawing transparent images that way, and it's not much more complex if at all complex.

GDI Tut

This is the link that I used when I was learning, but most the learning comes from experimenting with it.

Btw there is also the option of using a second form to overlay the original form, you could try setting the picture box on that form, and the transparency key to that, because the picture box is only transparent to it's parent form. If that makes sense.


So you're saying to use a picture box in this case is actually a better way of doing it than I currently am? Because currently I use nothing but a form. Everything else is drawn onto the form. I will check out this tutorial in the morning but I'm starting to think that using a form at all is a waste of energy and perhaps I should just create a 'canvas' of sorts...
Was This Post Helpful? 0
  • +
  • -

#6 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,499
  • Joined: 16-March 11

Re: Transparency Key

Posted 10 February 2012 - 01:31 AM

View Postjurdendurden, on 10 February 2012 - 02:05 AM, said:

View Posttrevster344, on 10 February 2012 - 12:12 AM, said:

Your problem is the picture boxes, I never figured it out myself, but I came to learn that using the GDI Classes is much more efficient, and suits the task much better. You'll be better off drawing transparent images that way, and it's not much more complex if at all complex.

GDI Tut

This is the link that I used when I was learning, but most the learning comes from experimenting with it.

Btw there is also the option of using a second form to overlay the original form, you could try setting the picture box on that form, and the transparency key to that, because the picture box is only transparent to it's parent form. If that makes sense.


So you're saying to use a picture box in this case is actually a better way of doing it than I currently am? Because currently I use nothing but a form. Everything else is drawn onto the form. I will check out this tutorial in the morning but I'm starting to think that using a form at all is a waste of energy and perhaps I should just create a 'canvas' of sorts...


No sir I said it'd be much better to draw instead of using a picture box, but you could use a picture box still and just use the double form method, your choice. :)
Was This Post Helpful? 0
  • +
  • -

#7 jurdendurden  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 39
  • Joined: 01-November 07

Re: Transparency Key

Posted 10 February 2012 - 07:10 AM

It confused me because in a previous post I mentioned that I wasn't using any objects whatsoever, other than the form itself. No pictureboxes here!
Was This Post Helpful? 0
  • +
  • -

#8 ricardosms  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 73
  • View blog
  • Posts: 301
  • Joined: 02-April 10

Re: Transparency Key

Posted 10 February 2012 - 08:50 AM

What are you drawing your maps on?
couldn't you set
pseudo code:
sprite.parent = mapObject


Was This Post Helpful? 0
  • +
  • -

#9 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,499
  • Joined: 16-March 11

Re: Transparency Key

Posted 10 February 2012 - 09:16 AM

I can't understand how you're getting sprites that are transparent to the form if you aren't using any objects, maybe you dont understand what an object is?

This post has been edited by trevster344: 10 February 2012 - 09:17 AM

Was This Post Helpful? 0
  • +
  • -

#10 ricardosms  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 73
  • View blog
  • Posts: 301
  • Joined: 02-April 10

Re: Transparency Key

Posted 10 February 2012 - 03:53 PM

If you paint your map on the form It should show.

The other way it occurs to me, is by screen capturing and clipping the sprite on it.
You may need to create a graphics path around your sprite and translate it with a matrix according to it's movements. Check these links:

For capture and clipping:

http://www.dreaminco...1&#entry1486705

For Translating:

http://www.dreaminco...1&#entry1474413

regards,
ricardosms.
Was This Post Helpful? 0
  • +
  • -

#11 jurdendurden  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 39
  • Joined: 01-November 07

Re: Transparency Key

Posted 19 February 2012 - 08:49 PM

View Posttrevster344, on 10 February 2012 - 09:16 AM, said:

I can't understand how you're getting sprites that are transparent to the form if you aren't using any objects, maybe you dont understand what an object is?


I'm drawing the 'actors' or 'sprites' just like I draw the map, directly to the form.
Was This Post Helpful? 0
  • +
  • -

#12 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,499
  • Joined: 16-March 11

Re: Transparency Key

Posted 19 February 2012 - 10:32 PM

Using what object?
Was This Post Helpful? 0
  • +
  • -

#13 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1043
  • View blog
  • Posts: 4,057
  • Joined: 02-July 08

Re: Transparency Key

Posted 19 February 2012 - 11:11 PM

View Postjurdendurden, on 19 February 2012 - 08:49 PM, said:

View Posttrevster344, on 10 February 2012 - 09:16 AM, said:

I can't understand how you're getting sprites that are transparent to the form if you aren't using any objects, maybe you dont understand what an object is?


I'm drawing the 'actors' or 'sprites' just like I draw the map, directly to the form.


He said he it's drawing on the form. I prefer a picturebox myself, better rendering.
Was This Post Helpful? 0
  • +
  • -

#14 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,499
  • Joined: 16-March 11

Re: Transparency Key

Posted 19 February 2012 - 11:31 PM

He said he wasn't using any picture boxes or objects which is why I'm confused lol. In an object oriented language how can you not use objects but anywho I like picture boxes but when it comes to transparency I really dislike them lol. Even though it's possible to work with it using picture boxes I really don't think it's the best method for a game.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1