Hi! I want to make a game with some blocks but not tetris and i need a hand . You know the minigame from professor layton?
In this one you have to change the position of the spheres, in mine you have to put a wooden block out of the game screen.
I started studying programming just a month ago and i'm a noob yet. The first test i did i used this code to move a block: [code] public function DocumentClass() { block1 = new Block(100, 200); addChild ( block1 ); block1.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); block1.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); } public function mouseDownHandler(evt:MouseEvent):void { var object = evt.target; // we should limit dragging to the area inside the canvas object.startDrag();
} public function mouseUpHandler(evt:MouseEvent):void { var obj = evt.target; obj.stopDrag(); } [/Code]
Whit this code i can move the block everywhere on the screen: that's not what i want. How can i write a code that give me the possibility of moving on lines set in advance? I explain better: the blocks have to move in only four directions: up, down, left and right and have to stop or don't move when collide with another block.
I know, i'm noob! That's why i'm here! Thanks in advance
Sorry man i didn't see the answer. This is the updated version: http://nonmichiamofredo.altervista.org/BlockQuest/BlockQuestBase2.swf I have to write a collisition code still. Have you got any istant messaging program? Such as skype or msn?
I don't have skype or msn though, but for collision detection and the coding behind that you should search for a tutorial or model something from flashkit.com. It really depends on what AS you are using and how you want to program your game. You may find that other ways are easier, but it really depends on how you want to code it.