Page 1 of 1

Draw a circle around the player using Canvas [SOLVED]

PostPosted: Tue Mar 20, 2012 6:44 pm
by Hblade
Hi, I want to make a room in my game where it's pitch black and you have a light that surrounds the player (This is done by a canvas covering the screen and its drawing solid black, but then uses some.. well, the question of this topic :P) The plan is, the circle will start bright in the center (about 32x32 with complete opacity), then get darker as it increases in distance. Any idea how to do this?

Example:
example.png



EDIT:
Solved and working amazingly :D

Re: Draw a circle around the player using Canvas

PostPosted: Tue Mar 20, 2012 6:45 pm
by Hblade
Hblade wrote:Hi, I want to make a room in my game where it's pitch black and you have a light that surrounds the player (This is done by a canvas covering the screen and its drawing solid black, but then uses some.. well, the question of this topic :P) The plan is, the circle will start bright in the center (about 32x32 with complete opacity), then get darker as it increases in distance. Any idea how to do this?

Example:
example.png




If this can't be done I have another plan.

Re: Draw a circle around the player using Canvas [SOLVED]

PostPosted: Wed Mar 21, 2012 4:20 pm
by jimmynewguy
Doing this with the canvas would be really slow I think. You might be better off making a sprite that is a light (like you have in your example) with a large black background and have it follower the player, if you get what I mean.

EDIT: Saw your edit. What did you end up doing?

Re: Draw a circle around the player using Canvas [SOLVED]

PostPosted: Wed Mar 21, 2012 4:38 pm
by Hblade
It was frightenly slow, so I used a gigantic image and placed it correctly. which was what you said :P Check out the game demos, Sky made a nice canvas effect for lighting. It's very interesting to say the least. I love it. It's in my realime lighting thingy.

Re: Draw a circle around the player using Canvas [SOLVED]

PostPosted: Thu Mar 22, 2012 7:22 pm
by RippeR7420
I ended up making an Actor called "Darkness", and changed the transparency a bit.

like this :)

Image

It doesn't look as good as yours does though haha :D

Re: Draw a circle around the player using Canvas [SOLVED]

PostPosted: Thu Mar 22, 2012 7:55 pm
by Hblade
You cna use mine if you want :)

Re: Draw a circle around the player using Canvas [SOLVED]

PostPosted: Thu Mar 22, 2012 7:56 pm
by RippeR7420
Awesome deal! thank you Hblade!

Re: Draw a circle around the player using Canvas [SOLVED]

PostPosted: Thu Mar 22, 2012 7:59 pm
by Hblade

Re: Draw a circle around the player using Canvas [SOLVED]

PostPosted: Thu Mar 22, 2012 8:00 pm
by Hblade
it might be too large, if so I can design you one.

Re: Draw a circle around the player using Canvas [SOLVED]

PostPosted: Fri Mar 23, 2012 6:33 am
by RippeR7420
Could you make me one in Iphone res. (480x320(Rotated left))?

Re: Draw a circle around the player using Canvas [SOLVED]

PostPosted: Fri Mar 23, 2012 1:34 pm
by Hblade
The thing is ripper, it has to be like 2.5 times larger than the original res, otherwise the black-area will vanish if the player is in a corner (Or the edge of the screen if your at the last part of the map) :P

So, whats the max resolution image an Iphone can handle?

Re: Draw a circle around the player using Canvas [SOLVED]

PostPosted: Fri Mar 23, 2012 3:10 pm
by Game A Gogo
I think it's 2048x2048, or 1024x1024, I forgot. Probably the smaller one

Re: Draw a circle around the player using Canvas [SOLVED]

PostPosted: Fri Mar 23, 2012 3:30 pm
by Hblade
Okay here ya go :3 grr uploader glitching out again DX so I have to use this, here :3
http://img835.imageshack.us/img835/4527/lightfl.png

Image