View Full Version : defend your castle like game
mongoose9990
October 2nd, 2006, 07:35 PM
hi
i was just wondering if any one could tell me or have links to any tutorials on how to make a defend your castle like game not really have all the upgrades but like how u pick up the people thanks
heres a link http://www.xgenstudios.com/play/castle
Thinker2501
October 2nd, 2006, 08:16 PM
The code below will let you pick up and drop those stick figures.
my_MC.onPress = function ():Void
{
this.startDrag();
};
my_Mc.onRelease = my_MC.onReleaseOutside = function ():Void
{
this.stopDrag();
};
LittleFenris
October 2nd, 2006, 08:41 PM
The code below will let you pick up and drop those stick figures.
That code you posted will let the user drag the stick figure around but certainly isn't enough to "drop" them as well. You'll need gravity and all that for the figures to actually "drop".
OP: Search for "gravity" in these forums to add to the above code so the figures will actually drop when you let go of the mouse button. For the different reactions of the figured depending on how far they are dropped you will need to know the distance from the "ground" which is fairly simple to figure out. Searching for "distance" or "calculate distance" will get you the info you need for that.
mongoose9990
October 2nd, 2006, 09:57 PM
i got the gravity sorted but wen i click on them and lift them up and then let go of them they still follow the mouse any help?
evildrummer
October 3rd, 2006, 10:39 AM
post what you have so we can work out why your gravity or dopping function isnt working.
mongoose9990
October 3rd, 2006, 06:39 PM
ok i have another problem, now that i put on the gravity code i cant grab them but before i could
i cant up load way too big even when zipped
so i will just post the guy if i can ....
no i cant does any one have any suggetions because it is 1.8mb !
THAnKS
Thinker2501
October 3rd, 2006, 06:46 PM
Optimize. There really isn't a need for a game like that to be that large, even if you do have sounds. At bar minimum post the code for your grav function and the code for the character.
LittleFenris: I know that code didn't include gravity, I was just pushing him in the right direction, not writing the whole app for him.
mongoose9990
October 3rd, 2006, 06:56 PM
ok the gravity kode is :
onClipEvent (load) {
gravity = 2
};
floor = 145;
bounce = 0.0 ;
speedx = 0 ;
speedy = 0 ;
}
onClipEvent (enterFrame) {
speedy = speedy + gravity ;
this._x += speedx/5 ;
this._y += speedy/5 ;
if (this._y > floor) {
this._y = floor ;
speedy *= -bounce ;
}
}
;
and the grab kode is :
my_MC.onPress = function ():Void
{
this.startDrag();
};
my_Mc.onRelease = my_MC.onReleaseOutside = function ():Void
{
this.stopDrag();
};
Nich
October 3rd, 2006, 07:22 PM
ok the gravity kode is :
onClipEvent (load) {
gravity = 2
};
floor = 145;
bounce = 0.0 ;
speedx = 0 ;
speedy = 0 ;
}
onClipEvent (enterFrame) {
speedy = speedy + gravity ;
this._x += speedx/5 ;
this._y += speedy/5 ;
if (this._y > floor) {
this._y = floor ;
speedy *= -bounce ;
}
}
;[/php] and the grab kode is :
[php]my_MC.onPress = function ():Void
{
this.startDrag();
};
my_Mc.onRelease = my_MC.onReleaseOutside = function ():Void
{
this.stopDrag();
};
I'm amazed you don't get an error with that. I'd say remove it, and test.
mongoose9990
October 3rd, 2006, 07:26 PM
lol remove what?
Nich
October 3rd, 2006, 08:24 PM
Sorry, was afraid that might happen. The bolded part :).
LittleFenris
October 3rd, 2006, 08:41 PM
LittleFenris: I know that code didn't include gravity, I was just pushing him in the right direction, not writing the whole app for him.
I was saying that in case they were new to AS'ing and didn't realize the gravity would be extra code.
evildrummer
October 4th, 2006, 08:48 AM
Well where are the seperate parts of code placed, on the enemy MC or on the timeline or what?
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.