Hello Guest

Author Topic: Documentation aimed at JavaScript  (Read 4740 times)

DanTsukasa

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 16
  • I love Games Design
    • View Profile
    • Team Ekko
Documentation aimed at JavaScript
« on: February 02, 2013, 09:04:59 pm »
This is my first post, I've been using 2dtk for a week or 2 now, plodding through tutorials around the net and things on here, however most unity tutorials I've come across seem to be using JavaScript wheras the documentation and script refference on here uses c#, I appreciate that I'm still learning code, but the constant back and forth isn't helping me or other make quick progress.

As another side note, all the 2D tutorials use twice the number of sprites for every direction, surely its less memory intensive to simply flip the sprite based on direction, if so, how best to go about this?
« Last Edit: February 02, 2013, 10:16:39 pm by DanTsukasa »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Documentation aimed at JavaScript
« Reply #1 on: February 03, 2013, 01:27:39 am »
Hi there,
I'll keep your input in mind for the next iteration of docs - it should be fairly trivial to write two versions, c# and JS.

You can flip your sprites by negating the horizontal scale, eg.
sprite.scale = Vector3(-1, 1, 1);

you can also call the flip function which toggles flipping.
sprite.FlipX();

You don't need 2 directions for all sprites, but it certainly does look better if you have different sprites moving left and right...

DanTsukasa

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 16
  • I love Games Design
    • View Profile
    • Team Ekko
Re: Documentation aimed at JavaScript
« Reply #2 on: February 03, 2013, 01:20:31 pm »
You can flip your sprites by negating the horizontal scale, eg.
sprite.scale = Vector3(-1, 1, 1);

you can also call the flip function which toggles flipping.
sprite.FlipX();

You don't need 2 directions for all sprites, but it certainly does look better if you have different sprites moving left and right...

Ah I see. Thanks for the speedy response, I'll give that a shot now and see what I get up.

Many games I've seen seem to use identical left and right animations for running, jumping, flying and whatever else, I may however make a few specific animations for certain angles.

The only other issue I have now is that my jump animation is slightly too long for the jump height, I can't really increase the height as its about perfect, but the animation still plays when hitting the floor, whilst I could speed up the FPS for the animation, it wouldn't suit so well. I'm completely unsure how best to go about that.