-
Move a character with touch
Hi,
I created a game in AS2 where you use the left and right keys to move a character left and right.
Would I be able to amend the below code (to AS3) so the same thing occurs by touching to the left or the right of the character?
Thanks
Matt
onClipEvent (load) {
speed = 5;
var crash:String = undefined;
}
onClipEvent (enterFrame) {
trace(crash);
if (Key.isDown(Key.LEFT) && crash == undefined) {
tellTarget ("/Raggles") {
gotoAndStop(2);
}
preXcor = _x;
_x -= speed;
_xscale = 100;
if (_x<265) {
_x = preXcor;
}
}
if (Key.isDown(Key.RIGHT) && crash == undefined) {
tellTarget ("/Raggles") {
gotoAndStop(2);
}
preXcor = _x;
_x += speed;
_xscale = 100;
tot = _x+this._width;
if (_x>860) {
_x = preXcor;
}
}
}
-
.
Hi,
I don't think you will get anybody to just convert it for you as it takes slightly more than just giving the code, you also need to publish for AIR(whichever one you need)
http://help.adobe.com/en_US/as3/dev/...a3d6-7ffe.html
It might be best if you get to grips with the environment you need first
-
Originally Posted by fruitbeard
Hi,
I don't think you will get anybody to just convert it for you as it takes slightly more than just giving the code, you also need to publish for AIR(whichever one you need)
http://help.adobe.com/en_US/as3/dev/...a3d6-7ffe.html
It might be best if you get to grips with the environment you need first
Hi,
It was really just to see if there was an alternative way:
I can't have like a button on the screen that if you click it activates the code. For example a button which when pressed tells a movieclip to go to frame 2. And the code i already posted instead of activating when the left key is pressed, activates if the aforementioned movieclip is on frame 2. I know its bastardised but honestly any roundabout way is fine with me at this point :/
Thanks in advance.
-
.
Hi,
You need AS3, the code is the same (virtually) as normal AS3 swf code, but you need touchEvents instead of mouseEvents etc etc
You also need to publish for AIR etc etc
You can have a button yes but it needs to be touched or swiped whichever you desire.
http://help.adobe.com/en_US/air/buil...d0cb-8000.html
http://stackoverflow.com/questions/2...s-and-desktops
I wish it could be more simple for you, but its not
AS3 doesnt use onClipEvent either
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|