Android studio development

Asked

Viewed 87 times

-3

I would like to know how to get an action in an Imageview , I put a character inside it and wanted it to jump . Remembering , I’m developing a game in Android Studio.

Thanks in advance.

  • 1

    Hello, please could you be more explicit? With images and some of the code please? Otherwise it becomes difficult

  • <Imageview android:id="@+id/txt_animation" android:layout_width="100dp" android:layout_height="100dp" android:layout_marginBottom="15dp" android:layout_marginStart="45dp" android:src="@drawable/animation" android:layout_alignParentBottom="true" android:layout_alignParentStart="true" />

  • I put inside the imageView an animation, where I want to put a jump action. My game is intended for the character to jump over obstacles if he touches any game over , otherwise he continues.....

  • Do not put the code here, put it in the indented form and put for example an image of the result here please.

  • The purpose of Imageview is show an image , was not planned to create character animations or anything like that. You can try to do something with it, but in reality you will be going to a lot of trouble while you could use some kind of library as libgdx.

  • But if I were to use an Imagemview for that function how would my code start?

  • Setting the height value?

  • But do you want me to tell you how I used to do it? Or the code I used to?

  • The code you used!

  • Kindly .

  • For I have no basis for starting.

  • Then I’ll answer your question below

  • I’ll wait for your answer!

Show 8 more comments

1 answer

0


Hello,

I avidly advise not using an Imageview for animation purposes and yes a library like libgdx that has support and ease.

But the logic I used would be this two Imageview. A Imageview that would be in the background and occupy the entire screen in fullscreen. And an Imageview that would match the character that would be at the bottom of the screen.

Something like:

xml layout.

<ImageView
    android:id="@+id/back"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scaleType="fitStart" >
    <ImageView
          android:id="@+id/char"
          android:layout_width="largura da personagem"
          android:layout_height="altura da personagem">
   </ImageView>
</ImageView>

main java.

 int number=100;
 //number corresponderia à posição atual da personagem e a maneira como mudaria no jogo
 ImageView s = (ImageView) findViewById(R.id.char);
 s.setY(number);
 s.setX(number)

I hope I have forwarded in game logic

  • Then I’ll have to put two Imageview and right after I put two images inside them right ? .

  • When I meant fullscreen , it would match one image after another?

  • Yes two Imageview with an image in each one. One would always be behind the background and the other would be the character

  • Good morning ! I would like to know how I can do that animation of credits at the end of the game , the letters rising ?

  • Please ask a new question and submit here the link of this question for me to answer. stackoverflow asks only one question per topic. And if I really helped you please close the topic by presenting my answer as a solution. Thank you

  • How do I present your answer as a solution ?

  • Just click on the tick/check symbol below the rating of the question.

  • Could you answer my question above?

  • Yes, I’m happy to answer, but please open a new question with this topic. Since it is the standard Stackoverflow method, 1 question per topic.

  • You are making a mistake when compiling .

  • <ImageView&#xA; android:id="@+id/back"&#xA; android:layout_width="match_parent"&#xA; android:src="@drawable/boneco"&#xA; android:layout_height="match_parent"&#xA; android:scaleType="fitStart" >&#xA; <ImageView&#xA; android:id="@+id/Chara" android:layout_width="wrap_content" android:src="@drawable/dummy" android:layout_height="wrap_content"> </Imageview> </Imageview>

  • No need to use Imageswitcher ?

  • But excuse what you intend to do with the Image?

Show 8 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.