Rotations and movements,

Hey,.

Thanks in advance for any answers or advice.

I'm doing a game where the user must "jump" from planet to planet. A rough explanation of the gameplay would be that the user needs to 'move' around a planet, align itself on the next planet and jumping to it. Hold the up arrow key move the user 'far' of the planet and release would be:

  • Let them be pulled back down by gravity if they are in the range of the planet,
  • Send them darting off in outer space due to lack of everything.
  • Or in the future make connected by a gravity of planets, prompting so partly through the level.

Currently, I make my character to move around the planet. I can then blow. While in the air, I can do a test to see whether or not they are close enough to a planet or not and act accordingly sending either the character forward at the same speed or decisions her land on the planet.

Arrises them question once I landed. I'm able to jump again and 'results' continuous work perfect, but I'm unable to turn around the planet, according to the needs.

addEventListener (Event.ENTER_FRAME, updateGame);

stage.addEventListener (KeyboardEvent.KEY_UP, KeyUp);

stage.addEventListener (KeyboardEvent.KEY_DOWN, KeyDown);

var keys: Array = [];

var currentPlayerState:String = "landed";

var walkSpeed:uint = 2;

var currentAngle:Number = 90;

var currentRadius:uint = planet.width/2;

var currentOrbitX:uint = planet.x;

var currentOrbitY:uint = planet.y;

var distanceX:Number;

var distanceY: number;

var distance: Number;

var dx:Number;

var dy:Number;

var newX:Number;

var newY:Number;

function KeyDown(e:KeyboardEvent):void {}

Keys [e.keycode] = true;

}

function KeyUp(e:KeyboardEvent):void {}

Keys [e.keycode] = false;

}

function updateGame(evt:Event) {}

checkKeyPresses();

Movement();

}

function checkKeyPresses() {}

{if (Keys [Keyboard.up])}

If (currentPlayerState == "landed") {}

currentPlayerState = "Skip";

}

}

If (keys [Keyboard.UP] == false) {}

If (distance > 100 + planet.width/2) {}

currentPlayerState = "drifting."

} else {}

currentPlayerState = 'falling ';

}

}

If (currentPlayerState == "landed") {}

rotateCharacter();

{if (Keys [Keyboard.Left])}

trace ("works of left")

currentAngle = walkSpeed;

}

If (keys [Keyboard.RIGHT] == true) {}

trace ("works of right");

currentAngle += walkSpeed;

}

}

}

function movement() {}

Switch (currentPlayerState) {}

case "jump":

checkDistance();

If (currentPlayerState == 'jump') {}

Agree = distanceX / distance;

y = distanceY / distance;

DX = - agree;

DY = - y;

Player.x += dx;

Player.y += dy;

}

break;

case 'falling ':

checkDistance();

if(distance > currentRadius) {}

Agree = distanceX / distance;

y = distanceY / distance;

DX = agree;

DY = y;

Player.x += dx;

Player.y += dy;

} else {}

currentPlayerState = "landed";

}

break;

'landed ': case

break;

case 'drifting ':

Player.x += dx;

Player.y += dy;

break;

}

}

function rotateCharacter() {}

var rad:Number = currentAngle * (Math.PI / 180);

Player.x = currentOrbitX + currentRadius * Math.cos (rad);

Player.y = currentOrbitY + currentRadius * Math.sin (rad);

Player.rotation =-(Math.atan2 (player.x-currentOrbitX,))

Player.y - currentOrbitY) * 180 / Math.PI);

}

function checkDistance() {}

distanceX = planet.x - player.x;

distanceY = planet.y - player.y;

distance = Math.sqrt (distanceX * distanceX + distanceY * distanceY);

}

In my real file the only funds I have are two movieclips. The two are already on the scene, one named 'planet', 150 x 150 and the orientation is in the Center. An other named 'player' which is around 20hx50w, orientation to the feet "power plants" of the movieclip.

Any matter or information which I'll get back to you as soon as POSSIBLE.

Thanks again.

You are checking if the button upwards and always set your status to fall. Check if you have landed in order to not accidentally put it:

If ((currentPlayerState == 'jump') & (keys [Keyboard.UP] == false))

{

If (distance > planet.width / 2 + 100)

{

currentPlayerState = "drifting."

} else {}

currentPlayerState = 'falling ';

}

}

Without checking if you jump, when UP is more pressed this continually sets your status as 'drifting' or 'falling', even if you "fell" and finally reached the planet and set. It would crush him. By checking if I was currently jumping, then just set the State so when I land it does not work.

Also one thing, you may want to consider is only under ENTER_FRAME keyDown and stopping the ENTER_FRAME, once you no longer need (e.g. landed).

Small example, at the top of your code to delete:

addEventListener (Event.ENTER_FRAME, updateGame);

Then add it when you really need:

function KeyDown(e:KeyboardEvent):void

{

Keys [e.keycode] = true;

addEventListener (Event.ENTER_FRAME, updateGame);

}

Delete if landed:

in the switch statement

'landed ': case

trace ("Landed, removing enterFrame");

removeEventListener (Event.ENTER_FRAME, updateGame);

It adds a very short deadline to keypress initial but you get the idea, it will save tons of unnecessary treatment.

Tags: Adobe Animate

Similar Questions

  • Rotate and move the 16-bit Image

    I would like to rotate and move a 16-bit RGB (U64 in LabVIEW) image.  The IMAQ turn and shift functions do not accept this type of image, but they do not accept an image in 16-bit grayscale (I16 in LabVIEW).  Unfortunately, this clips all values in my original image since it extends from-32, 767 to + 32 767.  The ExtractColorPlanes function requires a 16-bit image to be wired as the destination image but the IMAQ create VI does not U16 to create image.

    Any ideas?

    Just to be proactive... Here is an example of the problem.  I tried to download a (small) 16-bit tif, but is not a valid extension to download.  Photoshop allows me to record a 16-bit RAW, TIF or PSD: none of which can be downloaded.  Sorry for the inconvenience.

  • How image rotation and displacement by using different origins

    Hello
     
    I use LabVIEW 8.5 and 8.5 of Vision.
     
    I need to rotate, scale, and move a 2D image regarding one aspect of the image. I use IMAQ turn and shift, but I don't know what is the point of reference or originally used in this function. The coordinates of the image is very important in my application because I need these details to complete the recording of the image.

    My question is as below:

    (1) the origin (0,0) of an image is located in the upper left corner, can I change it to the center of the image?

    (2) how can I specified a certain point (coordinated) as a reference for the rotation and scale?

    Your help is very appreciated. Thank you.

    Hello

    Thanks for the idea, I'll try it soon.

    Best wishes

  • BlackBerry Z10 weird rotation and swipe

    Just an observation on the rotation and slide on the Z10.

    I normally have the Z10 in a loading dock that it was lying on its side.

    The screen and the icons are on the side and so I have to drag from right to left. When it moves to the active forms (e-mail for example) then rights itself and shows this screen standing and I can drag up from the bottom of the screen.

    Why so it a fashion landscape, all screens not only works in this mode and you move between slide everywhere (and make your head spin!) and upper (or annoyingly out of the docking station)?

    Thank you

    S

    You have a dock? From where?

    What you see, it is known and probably is fixed in OS entry versions. BlackBerry has to do all the rotating screens... and some users say that this question is exactly why BlackBerry itself has yet to release the loading OEM.

  • Animate using rotation and the puppet tool. Continuously rasterize mess it upward.

    In After Effects CC... Trying to animate a vector arms using rotation and the puppet tool. The animation looks good until I hit the button to rasterize continuously on this layer. He then gets distorted and cut out. I need to be continuously rasterized, so it's not pixelated.  Any suggestions on how to solve this would be great.

    In simple terms the effect of pupet pin uses space Composition and an alpha chanel of the first image to distort the pixels on the screen. So if you move or change the position or scale of the pixels after the first image to the assistance of any transformation or the effect, you now moved the original source of the pixels and puppets pin breaks. That's how the effect is designed and it's the only way it works.

    There is only a single correct workflow. Set up a model that is large enough to include all of the image that you want to animate when played back on the scale of 100% or a distance from the unit corresponding to the value of the camera zoom, if you size your layer of pine puppets if used in a comp. 3D IOW exceeds 100 percent in the final model, your computer is not big enough , or in a 3D model, if you want to move the camera at 1/4 the distance of the Zoom value of the camera to the layer of puppet pin your model of puppet PIN must be 4 times bigger.

    Animate the effect of pin puppet

    Bring the composition of spindle of puppets in yoiur main composition and apply other effects, transformations or any other manipulation, you need to perform to achieve your desired results.

    Puppet PIN is designed for this workflow and when used properly it is a very practical tool.

  • That means "use work and movement? ''

    When you open the window of information on an album, there is a checkbox for "use work and movement".  What does that mean?  Feel if you tick the box?

    Thank you!

    'Work' and 'movement' are designed for orchestral works - so does that music as Beethoven symphonies can be arranged.

  • 'Work and movement' (the most recent version of iTunes) ID3 tag bug

    I did experiment with new "work and movement" feature of iTunes, which is very convenient when the marking of classical music. I noticed a rather irritating bug, however: he resents as ¨ or ss, non-English characters. If the movement is titled "Fur bewegt," which in German means "lively", the characters 'Ä' and 'ss' are replaced by a strange diamond of sorts (similar to "") as soon as the track is. I can change it at the first spelling later, but the problem recurs whenever I have to replay the track. I want to bring this attention to Apple, so I hope I posted this in the right place.

    http://www.Apple.com/feedback/itunesapp.html

    I don't know anything firsthand about the new iTunes (I still use iTunes 7.5), but this kind of problem may also depend on you use character set.  I know that I can change that in my version of iTunes in the Advanced menu and you might try to experiment a different game.

  • file .avi and .mov on iMac changed in .m4v when they are copied to the external hard drive. I will be able to open these files on other devices like a Windows PC?

    file .avi and .mov on iMac changed in .m4v when they are copied to the external hard drive. I will be able to open these files on other devices like a Windows PC?

    FWIW, do not change the extensions of file simply by copying the files to an external drive.

  • Going crazy trying to select and move multiple points of tempo

    I tried to move a whole bunch of tempo of a bar points to a spot 4 bars later in my project. First time this... For the life of me I can't figure out what I'm doing wrong as I * try * follow the steps here: Logic Pro X: move and copy points of tempo

    Here's a quick screencast to choose me (while holding the CONTROL key) and then drag (hold down CTRL key):

    https://youtu.be/HpLHQbV4y9U

    (The editor let me not insert a video this time so I downloaded on YouTube instead.)

    I tried dragging dragging the first point of tempo, dragging from the last point of tempo, a place randomly in the Middle the selected points. I also tried now the shift and CONTROL simultaneously select and drag when he did not work on the other hand, only because the instructions mentioned the option to SHIFT + click in the selection. Finally, I tried the same thing while now the SHIFT key instead of CONTROL (don't wait not that it works of course because the instructions didn't say to do, but I tried the way described several times and she didn't).

    Get these points of tempo settles is the last detail in a huge song that ended the case

    There must be some small detail that I forgot the instructions. Any suggestions? Thanks in advance!

    Use the smudge tool to enter the automation of tempo and move it left or right...

  • How can I add a space to the toolbar in Firefox 29,0? I can enter a space between the empty boxes and move around, but where can I find an icon 'space' to ADD a space?

    It has been useful in previous versions of Firefox to be able to add (a) space (s) between the icons in the toolbar to create groups of icons and/or icons separated by class or function. In Firefox 29,0, I discovered how 'capture' (drag and drop) a space of areas in the open toolbar and move it to another part of the toolbar. But how do I add spaces to the toolbar? In previous versions, there used to be an icon of the space in the whole of the Customize menu that could drag it to the toolbar for this purpose.

    Sorry, the new UI Australis has abolished the 'space' to customize. There may be an extension for adding 'space', but I'm not aware of it.

  • How to select and move more than one bookmark at a time? Shift + click selects multiple items that are next to each other in a list, because the element

    How to select and move more than one bookmark at a time?
    Shift + click selects multiple items that are next to each other in a list, because the items open in firefox before that happens.

    Glad it worked for you. Thanks for posting back.

  • Pocket not mark as read and move on to the agenda

    When I click the play tab something pocket on Firefox, it continues to display the same article again and again. It does not mark it as read and move to the next item on my list.

    Hello if please contact directly the developers of extension by the way to their home page - they can probably give you more detailed advice and are the only ones who can fix bugs or make necessary adjustments in the addon. Thank you...

  • Copy and move broken rules

    Hello

    At one point in the upgrades of the Mavericks with El Capitan, broken rules in Apple Mail.

    I used to have a rule: If the [email protected] message arrives, copy it into an IMAP folder - so I can see it on my devices - and move it to my local folder for xyz.com

    It has worked well for years. Now what's happening is the position, the rules of the switch and since that movement occurs, the copy is not.

    I tried to delete and re-create the rules, but they always return to move before copy as soon as you close the window. When you return to Edit, Move is the first.

    Is there an action Applescript or automator can I run instead of the rule to restore the functionality I need?

    If these are two separate rules, mail-> Preferences-> drag window rules the rules in the correct order. Execution is top at the bottom of this window.

  • What is the best iPad to take pictures and movies?

    What is the best iPad in terms of quality for photos and movies?

    What is the best, is compared to your expectations.  Only you can decide.  It's a matter of opinion.

    That said, MY opinion is that no iPad should be used for recording movies and taking pictures.  The cameras are not good enough.  Use an iPhone or a digital camera / camcorder if you make movies.

  • On my iMac OSX El Capitan v 10.11.3 when editing of photos and work between them the screen takes over and moves the picture on the next picture before Ive had the chance to edit, I then fold the photo required to try again. This can hap

    On my iMac OSX El Capitan v 10.11.3 when editing of photos and work between them the screen takes over and moves the picture on the next picture before Ive had the chance to edit, I then fold the photo required to try again. This can happen several times and its so frustrating.

    Similar thing TI also occurs when you are working on other programs on the mac, but not nearly as much.

    Guessing here, but try to disable drag between pages on the tab more than movements in the system preferences > mouse. or a Trackpad. Depending on whether you are using.

Maybe you are looking for