我正在制作Flash游戏,我需要在角色和敌人的阴影底部。这里有大约35个动画,每个动画约有100帧。所以编辑每一帧,画阴影是不可能的。
我的角色的名字是英雄和对手的敌人。我需要做出像这样的东西总是在英雄的底部和敌人的阴影将被显示(阴影可以是圆形等)。只是在跳跃它应该重新调整大小(当角色/敌人在空中时,阴影应该更暗和更小)。
是否可以制作类似的东西?
这是我宣告敌人的方式:
public var Enemy:Priesas = new Priesas; //Priesas is instance name of Enemy
通过点击按钮选择Hero的模板:
public function selectHero(what:int):void {
// this is called with correct "what", design yourself. I use array index
var whatHero:Class = heroes[what]; // get selected hero symbol
if (Hero && Hero.parent) Hero.parent.removeChild(Hero);
// clean up previous hero. Drop listeners here, if any
Hero = new whatHero(); // get new hero
// process as usual, don't forget to "addChild(Hero)" somewhere
create_hero();
}
function choosePlayer(event:MouseEvent):void {
selectHero(0); // here is set first template for my Hero
start(event);
}
function create_hero()
{
addChild(Hero);
}
所声明的变量是:Hero
和Enemy
这是最简单的代码如何为角色Hero设置动画:
if (attack1)
{
enterFrameHandler();
Hero.gotoAndStop("attack1");
}
我不知道你是否有足够的信息,能帮帮我吗?
答案 0 :(得分:0)
创建一个MovieClip“Shadow”,它是你想要的任何形状的阴影。 创建另一个MovieClip'HeroWithShadow',其中包含你的Hero和Shadow。
public function selectHero(what:int):void {
// this is called with correct "what", design yourself. I use array index
var whatHero:Class = heroes[what]; // get selected hero symbol
if (Hero && Hero.parent) Hero.parent.removeChild(Hero);
// clean up previous hero. Drop listeners here, if any
Hero = new whatHero(); // get new hero
// process as usual, don't forget to "addChild(Hero)" somewhere
create_hero();
}
function choosePlayer(event:MouseEvent):void {
selectHero(0); // here is set first template for my Hero
start(event);
}
function create_hero(){
//create shadow
var shadow:Shadow = new Shadow();
//create container that will hold both hero and shadow
var heroWithShadow:HeroWithShadow = new HeroWithShadow();
//add both hero and shadow on heroWithShadow
heroWithShadow.addChild(Hero);
heroWithShadow.addChild(shadow);
//bring shadow to the bottom of hero
shadow.y = Hero.height;
addChild(heroWithShadow);
}
请注意,如果您想要水平移动英雄(步行),然后更新'heroWithShadow.x',如果您想垂直移动英雄(跳跃),请更新'Hero.y' 如果有效,请告诉我。