Copy link to clipboard
Copied
I want to create a matchstick puzzle. But I'm struggling with it.
the puzzle is like this
the player will have to move only 6 matches to get 3 squares
their are two solution for this
first one:
second:
i actually do not know how to accomplish this. If anyone here can provide me any help i'll be thankful.
thank you in advance.
Copy link to clipboard
Copied
create a matchstick movieclip.
arrange your movieclips to form the initial layout and assign instance names to your matchstick movieclips. add click event listeners to each one and on click move the clicked matchstick to a 'removal' pile. (clicking on a removed matchstick should return it to its original position.)
you can decide how to end game. eg, after 6 clicks, when the used clicks has a discard pile that contains one of the two groups etc.
Copy link to clipboard
Copied
i did that. i created the movie clips and added the instance name and added the event listener. and what you said is exactly what i want to do but i struggled with the coding. So if you have any idea of how to achieve this in action script i'll be thankful.
Copy link to clipboard
Copied
how to achieve which suggestion? i made two.
Copy link to clipboard
Copied
the removal pile one
Copy link to clipboard
Copied
var discardP:MovieClip=new MovieClip();
addChild(discardP);
discardP.x=?
discardP.y=?
var matchNum:int = 16;
for (var i:int=0;i<matchNum;i++){
this['match_'+i].addEventListener(MouseEvent.click,matchClickF):
}
function matchClickF(e:MouseEvent):void{
if(e.currentTarget.parent==discardP){
this.addChild(e.currentTarget);
} else{
discardP.addChild(e.currentTarget);
}
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now