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:
Sự đa dạng trong các mẫu mã và kiểu dáng của sản phẩm Đồ Thờ Gỗ cũng là điểm thu hút đặc biệt. Từ những tượng phật nhỏ xinh, đến các bức thư pháp hoặc các bát hương gỗ được điêu khắc tỉ mỉ, đều mang...
Tinh Thần Truyền Bá: Skyhome.vn và...