Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Facing of a Buff
#1
-> 
Actually, i never saw an explanation for this kind of things.
Also, search neither revelead something in the forum, nor on the mainsite.


This tut will explain, how to create a buff/upgrade/power-up which with automatically change the facing direction when the character does so.

As already known and public, a itr with kind: 8 will stick to the T0 it "hits". (For further information on itr/kind:8 you can check THIS link)
But it neither changes it's y-value, nor it's facing direction.

The problem is, if you now have, f.e., a guy punching.
This guy can upgrade his punch (with a move), so the punch will have some glow effect or whatever.
After the upgrade you turn around, punch... and the upgrade will spawn/create/show the glowing/whatever sprites still on the other side.

To prevent this you need following technique:
The kind:8-object has, instead 1, 2 itrs with kind:8.
Short info on Special Bodys (Click to View)
We will take a basic char stance for our example:
Usually, most characters have centerx: 39 and centery: 79 (last one is actually unimportant). Now you make 2 Special Bodys (it's possible to make about 10 bdys per frame, so don't worry about overloading the dat-file):
Code:
(...)centerx: 39  centery: 79(...)
   bdy:
      kind: 0  x: 49  y: 1230000  w: 50  h: 1000
   bdy_end:
As you can see on the x-coordinate, this Special Body is on the "right" of the character (since centerx: 39 is the middle). And "right" is the facing direction.

Now comes the tricky part: 2 itr/kind:8
Code:
(...)centerx: 39  centery: 79(...)
   itr:
      kind: 8  x: -71  y: 1230000  w: 100  h: 1000 dvx: abc
   itr_end:
   itr:
      kind: 8  x: 49  y: 1230000  w: 100  h: 1000 dvx: xyz
   itr_end:
Usually, an upgrade that is supposed to turn to the correct side is already "sticked to the char", it haves the same centerpoint. Since we are using the same centerx/y values for the char AND the object, getting the correct coordinates is quite easy (but you can of course use any values, it's just more calculating).
The first itr displayed above, reaches from -71 up to 29, the second one from 49-149. So, the first is left (behind) of the char, the second one right (in front).

If the char is facing the same direction as the object, the char will have the Special Body on the "right" side. Therefore, the second itr/kind:8 will trigger and bring the kinf:8-object to frame xyz (which could be the glowing sprites from the example noted above).

If the char is NOT facing the same direction, the Special Body will be on the "left" side. Now the first itr/kind:8 will trigger, which leads to frame abc.
This frame abc just haves a basic turning command (negative next value), leading back to xyz.


In effect:
The kind:8-object will ALWAYS have the same facing as the char with the Special Body itself.



Free for discussions, comments and critics now, is the first tut i've ever written :D
My Creations: (Click to View)

Return (String) System.getNewsOfTheDay();
Barely active, expect slow responses. If at all.


Greetz,
Alblaka
Reply
Thanks given by: MH-Razen , Bamboori , no one


Messages In This Thread
Facing of a Buff - by Alblaka - 01-13-2010, 07:13 AM
RE: Facing of a Buff - by Bamboori - 01-13-2010, 01:21 PM
RE: Facing of a Buff - by no one - 01-13-2010, 02:37 PM
RE: Facing of a Buff - by Bamboori - 01-13-2010, 02:49 PM
RE: Facing of a Buff - by Alblaka - 01-13-2010, 03:02 PM
RE: Facing of a Buff - by mammoth - 01-16-2010, 04:54 PM
RE: Facing of a Buff - by Alblaka - 01-16-2010, 05:02 PM
RE: Facing of a Buff - by The Lost Global Mod - 01-16-2010, 07:39 PM
RE: Facing of a Buff - by mammoth - 01-16-2010, 08:17 PM



Users browsing this thread: 2 Guest(s)