Does anyone know a simple code where I can make a reflection for an entire MovieClip/Or layer?(example below)
Tutorials on google and youtube were of no help sadly.
Does anyone know a simple code where I can make a reflection for an entire MovieClip/Or layer?(example below)
Tutorials on google and youtube were of no help sadly.
At 4/11/13 04:23 AM, TechLeSSWaYz wrote: Does anyone know a simple code where I can make a reflection for an entire MovieClip/Or layer?(example below)
Tutorials on google and youtube were of no help sadly.
I can help YOU do it:
1. Create a bitmap and a bitmapdata object
2. "Draw" the movieclip that requires a reflection onto the bitmapdata object
3. Create a matrix which rotates and FLIPS (must flip or else each end of the object will reverse) - very easy
4. Create a simple color filter (again this is quite easy) that creates a linear alpha gradient or you can simply just change the bitmap object's alpha if you wanted to (much easier)
5. Apply the matrix & color filter
6. Change the bitmap object's bitmapData object to the new one that you made using steps 1-5
Should take you less than 15 minutes. The hard part is optimisations for animated movieclips or if you want to incorporate this into a blitted game. :P
At 4/11/13 06:44 AM, 64base wrote: Should take you less than 15 minutes. The hard part is optimisations for animated movieclips or if you want to incorporate this into a blitted game. :P
Isn't it easier to create a coded duplicate of the MC and simply yadadada flip, turn and alpha that?
What's more resource efficient actually? A duplicate of MC itself or AS coded?
At 4/11/13 02:18 PM, Pkmn2 wrote:At 4/11/13 06:44 AM, 64base wrote: Should take you less than 15 minutes. The hard part is optimisations for animated movieclips or if you want to incorporate this into a blitted game. :PIsn't it easier to create a coded duplicate of the MC and simply yadadada flip, turn and alpha that?
Probably not. Applying the alpha would be hard.
What's more resource efficient actually? A duplicate of MC itself or AS coded?
Definitively bitmap duplication.
I can help YOU do it:
You just confused me to the fullest...
At 4/11/13 03:27 PM, TechLeSSWaYz wrote:I can help YOU do it:You just confused me to the fullest...
You could find a class to do it for you.
If you were using AS3. You can try to port a class back to the dinosaur that is AS2
At 4/11/13 07:29 PM, MintPaw wrote:At 4/11/13 03:27 PM, TechLeSSWaYz wrote:You could find a class to do it for you.I can help YOU do it:You just confused me to the fullest...
If you were using AS3. You can try to port a class back to the dinosaur that is AS2
Sadly I'm using AS2... but its alright. I can always do it manually. but id rather not
At 4/11/13 07:40 PM, TechLeSSWaYz wrote:At 4/11/13 07:29 PM, MintPaw wrote:Sadly I'm using AS2... but its alright. I can always do it manually. but id rather notAt 4/11/13 03:27 PM, TechLeSSWaYz wrote:You could find a class to do it for you.I can help YOU do it:You just confused me to the fullest...
If you were using AS3. You can try to port a class back to the dinosaur that is AS2
Actually it might not be that hard, depending on what exactly you need reflected, if it's the whole screen it's shouldn't be that hard. But if it's like specific objects on a specific part of the screen have to be reflected on another location you'll need to be a lot more code savvy.
Actually it might not be that hard, depending on what exactly you need reflected, if it's the whole screen it's shouldn't be that hard. But if it's like specific objects on a specific part of the screen have to be reflected on another location you'll need to be a lot more code savvy.
Basically I just need the sprite characters reflecting off the ground.
At 4/11/13 08:19 PM, TechLeSSWaYz wrote:Actually it might not be that hard, depending on what exactly you need reflected, if it's the whole screen it's shouldn't be that hard. But if it's like specific objects on a specific part of the screen have to be reflected on another location you'll need to be a lot more code savvy.Basically I just need the sprite characters reflecting off the ground.
Yeah, then I'd just add a inverted version of the character graphic and have it follow around the player.
At 4/11/13 08:39 PM, MintPaw wrote:At 4/11/13 08:19 PM, TechLeSSWaYz wrote:Yeah, then I'd just add a inverted version of the character graphic and have it follow around the player.Actually it might not be that hard, depending on what exactly you need reflected, if it's the whole screen it's shouldn't be that hard. But if it's like specific objects on a specific part of the screen have to be reflected on another location you'll need to be a lot more code savvy.Basically I just need the sprite characters reflecting off the ground.
So like.. duplicate all of the characters frames in a separate movie clip? since its in a movie clip I just have to position it needed and alpha it? :D
That's not all, you also need to do the fade part.
You'll need to draw a rectangle of any color, and make it gradient from 0 alpha to 100 alpha.
Convert the rectangle to movie clip and put it inside character's animation clip.
Place it somewhere on a new layer which has 1 keyframe, and have it present during entire animation.
Remember that the visible part should be on top (it should cover character's head), and invisible part on bottom.
Set the rectangle's blend mode to 'erase'.
Name the rectangle instance 'mask'.
During the game, you'll need to create 2 clips for each character, one called 'unit'+i, the other 'reflection'+i.
In 'unit'+i make the 'mask' _visible=false. As for 'reflection'+i , set its blend mode to 'layer' and put it under a mask for water reflections.
Uhh, I am not sure you understand everything I say? Is this clear what I'm trying to say, do I need to create an example in Flash?
So I made a test project for character reflections.
This SWF is how it looks in the end.
Now I will describe how to do this in Flash 8 Professional.
[list=1]
[*] Make a new document.
[*] Draw your stage.
[*] Draw ponds of water in separate layer.
[*] Copy all ponds.
[*] Paste them in a new empty layer.
[*] Select all new copied ponds and convert them all to a movie clip.
[*] Give the movie clip an instance name of 'ponds'.
[*] Now you have 2 same ponds: ones lie on level picture, others are copied to 'ponds' and are separate, but same.
[*] Get some character animation. (Without anything special on it, yet.)
[*] Put the character clip on the level, name it 'hero'.
[*] Edit your character animations.
[*] Make a new layer on top of everything.
[*] Draw a very big rectangle which covers whole possible area, where character's animation can reach.
[*] Make the rectangle gradient from blue 0% alpha to blue 100% alpha.
[*] Make sure the 100% alpha part is on top (covers the head), 0% alpha part is at bottom (covers the legs). There's a gradient transform tool to rotate the gradient.
[*] Convert the rectangle to a movie clip and give it an instance name of 'eraser'.
[*] Set the rectangle's blend mode to 'erase' in Properties Inspector.
[*] Go to main stage and put this code:
[code]
duplicateMovieClip(hero,"reflection",0);
reflection.setMask(ponds);
reflection._yscale=-100;
hero.eraser._visible=false;
reflection.blendMode="layer";
onEnterFrame=function(){
//your game code here
reflection._x=hero._x;
reflection._xscale=hero._xscale;
reflection.gotoAndStop(hero._currentframe);
}
[/code]
Here is FLA file for more detail on how it is all done.
Here is FLA file for more detail on how it is all done.
whoa. seems simple o_o thanks for the detailed tutorial! you should really make a youtube tutorial about this.
Im so adding you to the credits.