Is it possible to assign graviity (Physics game gravity) to a label or text box or image view?
Actually, My aim is to make simple and smooth animations of image view or text area. So, without using libgdx, I want to animate and do some smalll gamings.
Is it possible to assign graviity (Physics game gravity) to a label or text box or image view?
Actually, My aim is to make simple and smooth animations of image view or text area. So, without using libgdx, I want to animate and do some smalll gamings.
Also try AnimationPlus library using which you can set animation interpolators like bounce, overshoot, accelerate etc.. which will simulate gravity to a small level
My game physics are based on this simple example: http://jsfiddle.net/LyM87/
Although it's JAVA code, it's simple enough to be understood and ported to B4A.
Gravity basically works like this:
B4X:
Dim gravity = (9.8 / 60) AS Float
Dim velocityY = 0 AS Float
Dim positionY = 0 AS Float
Label1.Top = positionY
Do
'The object will fall until it reaches the bottom of the screen.
'Assuming that this loop runs 60 times per second, your object
'will accelerate 9.8 pixels per second, every second.
If positionY < (100%y - Label1.Height) then
velocityY = velocityY + gravity
positionY = positionY + velocityY;
Label1.Top = positionY
Else
Label1.Top = (100%y - Label1.Height)
End If
Loop
Disclaimer: This code wasn't tested nor should it be implemented as is.
This is more like pseudo-basic-code. You're better off using a Timer(16ms) rather than a Do...Loop cycle.