Mọi thứ đều hoạt động tốt chỉ duy nhất sự kiện Tap trong Update() không hoạt động !... Mấy anh nào có kinh nghiệm giúp e với ?????
Mã:
class Animation { Texture2D texture; Rectangle rectanle; Vector2 pos; Vector2 tmp_pos; Vector2 origin; //MenuButtons _jump = new MenuButtons(); int currentFrame; int heightFrame; int widthFream; float timer; float interval=75; public bool touch; bool jump; //Rectangle tv; public void Load(ContentManager Content) { texture = Content.Load<Texture2D>("Image/Pig"); pos = new Vector2(180, 320); heightFrame = 58; widthFream = 70; jump = false; touch = false; //_jump.position = new Vector2(0,0); //_jump.texture = Content.Load<Texture2D>("Jump"); } public void Update(GameTime gameTime) { //Animation rectanle = new Rectangle(currentFrame * widthFream, 0, widthFream, heightFrame); origin = new Vector2(rectanle.Width / 2, rectanle.Height / 2); if (jump == false) AnimateRight(gameTime); //Jump pos.Y += tmp_pos.Y; while (TouchPanel.IsGestureAvailable) { GestureSample ges = TouchPanel.ReadGesture(); if (ges.GestureType == GestureType.Tap) touch = true; } if (touch == true) Jump(); } public void Jump() { if(jump==false) { pos.Y -= 10f; tmp_pos.Y = -15f; if (pos.Y < 100) jump = true; } if (jump == true) { float i = 1f; tmp_pos.Y += 0.15f + i; } if (pos.Y + heightFrame > 320) { jump = false; touch = false; pos.Y = 320; } if (jump == false) { tmp_pos.Y = 0f; } } public void AnimateRight(GameTime gameTime) { timer += (float)gameTime.ElapsedGameTime.TotalMilliseconds / 2; if (timer > interval) { currentFrame++; timer = 0; if (currentFrame > 1) currentFrame = 0; } } public void Draw(SpriteBatch sp) { sp.Draw(texture, pos, rectanle, Color.White, 0f, origin, 1.0f, SpriteEffects.None, 0); //sp.Draw(_jump.texture, _jump.position, Color.White); } }
View more random threads:
Pallet nhựa Lâm Đồng giải pháp hoàn hảo cho nhà kho Pallet nhựa Lâm Đồng là một giải pháp đa năng và hiệu quả trong việc vận chuyển và lưu trữ hàng hóa. Trong đó, pallet nhựa Lâm Đồng không chỉ đáp...
Pallet nhựa Lâm Đồng giải pháp...