Android Question First game. Easy image animation ?

achtrade

Active Member
Licensed User
Longtime User
Hello,

I'm about to create my first game, very simple.

What I want is move an image from left to right and vice versa. For instance, the image is in the left side, if I tap the screen, the image start to move slowly to the right until reach the right edge. That's all.

Any suggestion or tutorial to do this.

thanks.
 

achtrade

Active Member
Licensed User
Longtime User
I did it and found a lot of tutorials, actually, now I'm reading the flappy bird clone tutorial, but this is too much for me, for now I need something very simple.

I hope someone has a tutorial for my simple animation.
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
add a timer to your program.

B4X:
dim timer1 as timer
timer1.initialize("moveright",1000/25)    '1000/25 = 25 frames per second
timer1.enable=false

when they click on the image you do a

B4X:
timer1.enable

in the timer tick sub you use

B4X:
sub moveright_tick
if image.left=100%x-imageleft then  ' this check if the image is at the right side of the activity. 100%x is when it goes out of the screen
timer1.enable=false
else
img1.left=img1.left+1
end if
end sub

that's the basic movement, not really a library needed to do this.

you should think if a gaming lib is really needed and this depends on the complexity of the game.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…