# Delta Function

### » Thu Mar 13, 2008 6:20 pm

Is there a delta function?
B
2
S
2
G
4
Posts: 136
Reputation: 1,722

### » Thu Mar 13, 2008 6:31 pm

I'm not sure what you're referring to. These delta functions? The TimeDelta expression?
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

### » Thu Mar 13, 2008 6:46 pm

http://en.wikipedia.org/wiki/Delta_%28letter%29

The way I understand it is that it's the rate of change of a number.
B
2
S
2
G
4
Posts: 136
Reputation: 1,722

### » Thu Mar 13, 2008 7:17 pm

Δx simply means the change in x, for example, if you wanted to track the change in the mouse X co-ordinate, you'd just subtract the old mouse co-ordinate from the new one.

You might be referring to differentiation, in which case no, that's mathematically fairly advanced and beyond the scope of your typical game.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

### » Thu Mar 13, 2008 7:19 pm

Where would I get the old coordinate of an object then?
B
2
S
2
G
4
Posts: 136
Reputation: 1,722

### » Thu Mar 13, 2008 7:21 pm

Just store it in a private variable, eg:

Always
> Text object: set text to Sprite.X - Sprite('OldX')
> Sprite: Set 'OldX' to Object.X

The text object will show the change, frame-by-frame, in the X co-ordinate.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

### » Thu Mar 13, 2008 8:56 pm

[quote="Ashley":i52e4k9r]Just store it in a private variable, eg:

Always
> Text object: set text to Sprite.X - Sprite('OldX')
> Sprite: Set 'OldX' to Object.X

The text object will show the change, frame-by-frame, in the X co-ordinate.[/quote:i52e4k9r]

Yep, that's how my platform engine tells the difference between jumping and falling. Y < oldY = jumping, and y > oldY = falling. Good for controlling animations.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

### » Thu Mar 13, 2008 10:05 pm

What would Object.X be though? Do I attach a second invisible sprite to the character or... what?
B
2
S
2
G
4
Posts: 136
Reputation: 1,722

### » Thu Mar 13, 2008 10:54 pm

Sorry, stuffed that one up. Should've been Sprite.X:

Always
> Text object: set text to Sprite.X - Sprite('OldX')
> Sprite: Set 'OldX' to Sprite.X
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580