Actionscript 3 用Flash制作化学游戏的最佳thinkflow?
所以,正如前面提到的,我这学期要做一些Flash…我想我知道如何在Python中完成这项工作,包括类和所有内容,但在AS3中,一切都是如此…独立的 我想做一个简短的化学游戏。你有4种元素,火、土、风和精神,但水不见了,关键是要制造水。舞台上有火、风、土、灵和锅。单击它们会在锅中添加一滴 您必须按照非常特定的顺序将元素放入其中,但是如果您搞砸了,计数将重置,您必须重新启动。顺序是火、灵、土、火、灵、风。(目前非常武断,但可以这样说) 我将如何在AS3中实现这一点 (这些标签是用来帮助那些想制作这种特定游戏的人的) 这是我当前的代码Actionscript 3 用Flash制作化学游戏的最佳thinkflow?,actionscript-3,chemistry,Actionscript 3,Chemistry,所以,正如前面提到的,我这学期要做一些Flash…我想我知道如何在Python中完成这项工作,包括类和所有内容,但在AS3中,一切都是如此…独立的 我想做一个简短的化学游戏。你有4种元素,火、土、风和精神,但水不见了,关键是要制造水。舞台上有火、风、土、灵和锅。单击它们会在锅中添加一滴 您必须按照非常特定的顺序将元素放入其中,但是如果您搞砸了,计数将重置,您必须重新启动。顺序是火、灵、土、火、灵、风。(目前非常武断,但可以这样说) 我将如何在AS3中实现这一点 (这些标签是用来帮助那些想制作这种
stop();
lvln.text="Phase 3 - Bargaining";
import flash.events.MouseEvent;
import flash.display.MovieClip;
import flash.events.Event;
const WIDTH:int=50;
const HEIGHT:int=50;
const SEPX:int=50;
var fireb:firebtn=new firebtn();
var spiritb:spiritbtn=new spiritbtn();
var earthb:earthbtn=new earthbtn();
var windb:windbtn=new windbtn();
var combo:Array=new Array();
var truecombo:Array=[fireb,spiritb,spiritb,windb,earthb];
var lastElm=combo[combo.length-1];
firebb.addEventListener(MouseEvent.CLICK, fire1);
windbb.addEventListener(MouseEvent.CLICK, wind1);
earthbb.addEventListener(MouseEvent.CLICK, earth1);
spiritbb.addEventListener(MouseEvent.CLICK, spirit1);
function add1(clip:DisplayObject)
{
if (combo.length > 6)
{
combo.shift();
combo.push(clip);
reorder();
}
}
function reorder()
{
for(var i:int = 0; i < combo.length; i++)
{
combo[i].x = i * 50;
}
}
function fire1(e:MouseEvent)
{
lastX+=SEPX;
twist.gotoAndPlay(2);
var fireb:firebtn=new firebtn();
stage.addChild(fireb);
add1(fireb);
fireb.width=WIDTH;
fireb.height=HEIGHT;
fireb.x=lastX;
fireb.y=lastY;
pop.play();
}
function wind1(e:MouseEvent)
{
lastX+=SEPX;
twist.gotoAndPlay(2);
var windb:windbtn=new windbtn();
stage.addChild(windb);
add1(fireb);
windb.width=WIDTH;
windb.height=HEIGHT;
windb.x=lastX;
windb.y=lastY;
pop.play();
}
function earth1(e:MouseEvent)
{
lastX+=SEPX;
twist.gotoAndPlay(2);
var earthb:earthbtn=new earthbtn();
stage.addChild(earthb);
add1(fireb);
earthb.width=WIDTH;
earthb.height=HEIGHT;
earthb.x=lastX;
earthb.y=lastY;
pop.play();
}
function spirit1(e:MouseEvent)
{
lastX+=SEPX;
twist.gotoAndPlay(2);
var spiritb:spiritbtn=new spiritbtn();
stage.addChild(spiritb);
combo.push(spiritb);
spiritb.width=WIDTH;
spiritb.height=HEIGHT;
spiritb.x=lastX;
spiritb.y=lastY;
pop.play();
}
stop();
lvln.text=“第3阶段-谈判”;
导入flash.events.MouseEvent;
导入flash.display.MovieClip;
导入flash.events.Event;
常数宽度:int=50;
常数高度:int=50;
常数SEPX:int=50;
var fireb:firebtn=新的firebtn();
var-spiritb:spiritbtn=new-spiritbtn();
var earthb:earthbtn=新的earthbtn();
var windb:windbtn=新的windbtn();
变量组合:数组=新数组();
var truecombo:Array=[fireb,spiritb,spiritb,windb,earthb];
var lastElm=combo[combo.length-1];
firebb.addEventListener(MouseEvent.CLICK,fire1);
windbb.addEventListener(MouseEvent.CLICK,wind1);
earthbb.addEventListener(MouseEvent.CLICK,earth1);
spiritbb.addEventListener(MouseEvent.CLICK,spirit1);
函数add1(剪辑:DisplayObject)
{
如果(组合长度>6)
{
combo.shift();
组合。推(夹);
重新排序();
}
}
函数重新排序()
{
for(变量i:int=0;i
我会这样做。
所以你有4个元素。为它们中的每一个制作一个按钮/MovieClip(当你点击其中一个按钮/MovieClip时,它就会填满锅),这就是你必须处理的动画。但要检查组合是否正确,请使用此代码
import flash.events.MouseEvent;
import flash.events.Event;
var combination:Array=new Array(); //Array that loads elements being clicked
var clength:Number = 0; // combination length for making water
var truecombination:Array=new Array(); // Array that holds combination for making water
truecombination.push("fire"); //first element
truecombination.push("wind"); //second element
truecombination.push("spirit"); //third element
truecombination.push("fire"); //fourth element
truecombination.push("wind"); // fifth element
truecombination.push("earth"); //sixt element(you can go for more elements in your combination but remember to change the clength variable)
//adding event listeners for elemnt buttons
fire_mc.addEventListener(MouseEvent.CLICK, fclick);
wind_mc.addEventListener(MouseEvent.CLICK, wclick);
spirit_mc.addEventListener(MouseEvent.CLICK, sclick);
earth_mc.addEventListener(MouseEvent.CLICK, eclick);
//you can also add animation labels to the functions below to make the game more interesting
function fclick(e:MouseEvent):void
{
combination.push("fire");
clength+=1;
}
function wclick(e:MouseEvent):void
{
combination.push("wind");
clength+=1;
}
function sclick(e:MouseEvent):void
{
combination.push("spirit");
clength+=1;
}
function eclick(e:MouseEvent):void
{
combination.push("earth");
clength+=1;
}
addEventListener(Event.ENTER_FRAME,loop);//making a loop function that checks the combination
function loop(e:Event):void
{
if (truecombination.length => 6) //waiting for player to enter his combination
{
if (combination[clength-6] == "fire" && combination[clength-5] == "wind" && combination[clength-4] == "spirit" && combination[clength-3] == "fire" && combination[clength-2] == "wind" && combination[clength-1] == "earth") //checking if combination is true
{
trace("You Won");
}
else // and if it is not true...
{
//trace("You Lose");
}
}
}
我希望这对你有所帮助你可能想从开始,这样你就可以更好地了解如何开始。事实上,我对AS3有一个很好的理解……问题是这件事超出了我的能力范围,所以也许一些暗示可以给我一些帮助……例如,我可以找到解决AS3中许多问题的方法(当然是通过一些谷歌)但是这个想法看起来很复杂,就像我想的,但是失去的情况呢?没有真正的损失。我希望阵列在最后6次点击时一直更新,如果它们与“truecombo”匹配,那么你赢了。有没有办法保持最后6次点击,当点击一次新的点击时,删除最旧的一次?没有……我想说的是,组合应该总是更新,总是只保持最后6次点击,而不是等待6次点击,然后将其归零。我知道“轮班”的事,但有点不管用。此外,我希望迷你版重新定位自己。请查看我新编辑的问题。我再次编辑了代码。现在,计算机总是填充组合数组,并检查一行中每6个元素的组合是否为真,直到它为真。我使用我的代码是因为它对我来说更容易编辑,但关键是你明白我制作游戏的想法。祝你好运!