-
Virtual Key or alternative.
Hi,
I currently have a small game working in flash where you use the keyboard to move the character left and right, this works fine. I have also converted it through swiffy to run tablets, ok fine.
The issue is that it is the left and right keyboard keys which are used to move the character, and these aren't present on the tablet. So either I need to make it think the keys have been pressed, or replace the key press code with something else, any suggestions?
Here's the code on the movie clip (note the 'Raggles frame 2 is just a frame where the character animates)
Many 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,
Perhaps you can try using A & D keys
a key
PHP Code:
if (Key.getCode() == 65 && crash == undefined)
d key
PHP Code:
if (Key.getCode() == 68 && crash == undefined)
here is a list of other keys
http://www.makeflashgames.com/resources/keycodes.php
or
http://fornstrom.tjcomputermagnet.co...shKeyCodes.pdf
and here is some advice/code on it
http://docs.brajeshwar.com/as2/Key.html
-
Originally Posted by fruitbeard
Hi
It's more that there is no keyboard at all on the tablet so i was hoping there was a way to make a clickable button where the game thought it had been clicked or to alter the above code so that a standard flash button will cause the same effect.
Thanks
Matt
-
.
Hi,
I have no experience with tablets, if it's touch screen then you will need to make your flash app using air.
With AS3 code such as MultitouchInputMode, TransformGestureEvent
-
Is there an alternative way to do this i.e. rather than having the character move left when the left key is held down, have the character move left whenan on screen button is pressed?
-
I am just unsure of the alternative coding to this piece:
if (Key.isDown(Key.LEFT) && crash == undefined) {
tellTarget ("/Raggles") {
gotoAndStop(2);
-
.
Hi,
As far as I am aware, you are going to need to use air and AS3 to publish flash for mobiles and tablets, you will need to use touch events.
http://help.adobe.com/en_US/FlashPla...ouchEvent.html
in your case I think flash.events.PressAndTapGestureEvent along with the associated var being true
-
Originally Posted by fruitbeard
Hi,
As far as I am aware, you are going to need to use air and AS3 to publish flash for mobiles and tablets, you will need to use touch events.
http://help.adobe.com/en_US/FlashPla...ouchEvent.html
in your case I think flash.events.PressAndTapGestureEvent along with the associated var being true
Hi,
Thanks again for the help. Does this mean I can't make it so rather than the event happening when the left key is pressed, the same event happens when an on screen button is pressed?
Thanks
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
|