Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8379337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:09:20+00:00 2026-06-09T16:09:20+00:00

This is the method i use to fly through my sprite sheet. In the

  • 0

This is the method i use to fly through my sprite sheet. In the object class i keep track of the information and do all the cycling, this basically just needs to assign the texture-mapping coords. only it doesn’t seem to be working. But i logged the way i flip through the rows/columns and it is cycling correctly. But I see nothing as far as a texture. at all. am I missing something?

    public void SetToAnimatedTexture(int NumFramesWide, int NumFramesTall, int CurrentRow, int CurrentColumn) {
    /***************************************************************************************** 
     * This Assembles our Vertices in the correct spots by disassembling
     * our custom rectangles corners, and adds animation. Call this after creating the meshRect
     * *****************************************************************************************/

    float frameWidth = 1/NumFramesWide;
    float frameHeight = 1/NumFramesTall;

    float u1 = frameWidth*CurrentColumn;
    float u2 = (frameWidth*CurrentColumn) + frameWidth;
    float u3 = (frameWidth*CurrentColumn) + frameWidth;
    float u4  = frameWidth*CurrentColumn;

    float v1 = (frameHeight*CurrentRow) + frameHeight;
    float v2 = (frameHeight*CurrentRow) + frameHeight;
    float v3 = frameHeight*CurrentRow;
    float v4 = frameHeight*CurrentRow;

    ByteBuffer byteBuffer = ByteBuffer.allocateDirect(4 * VERTEX_SIZE);
    byteBuffer.order(ByteOrder.nativeOrder());
    vertices = byteBuffer.asFloatBuffer();

    float x1 = (float) rect.BottomLeftCorner.x;
    float x2 = (float) rect.BottomRightCorner.x;
    float x3 = (float) rect.TopRightCorner.x;
    float x4 = (float) rect.TopLeftCorner.x;

    float y1 = (float) rect.BottomLeftCorner.y;
    float y2 = (float) rect.BottomRightCorner.y;
    float y3 = (float) rect.TopRightCorner.y;
    float y4 = (float) rect.TopLeftCorner.y;

    vertices.put(new float[] { x1, y1, 1, 1, 1, 1, u1, v1,
                                x2, y2, 1, 1, 1, 1, u2, v2,
                                x3, y3, 1, 1, 1, 1, u3, v3,
                                x4, y4, 1, 1, 1, 1, u4, v4 });
                            //  x   y   r  g  b  A   u|s  v|t
                            //  x,y are coordinates
                            //  rgba = color red green blue alpha
                            //  u|s v|t = UV or ST texture coordinates
    vertices.flip();

    byteBuffer = ByteBuffer.allocateDirect(6 * 2);
    byteBuffer.order(ByteOrder.nativeOrder());
    indices = byteBuffer.asShortBuffer();
    indices.put(new short[] { 0, 1, 2,
                                2, 3, 0 });
    indices.flip();

}

this is part of a framework i have been setting up for myself.

Ok figured out the issue by doing some logging. this right here is the probelm

    float frameWidth = 1/NumFramesWide;
    float frameHeight = 1/NumFramesTall;

it is returning both values as 0.
it says

    1/2=0 , 1/4=0

i checked the value of all the variables and this is the issue.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T16:09:22+00:00Added an answer on June 9, 2026 at 4:09 pm

    It’s doing integer division first and then assignment. Since both 1 and NumFrames* are integers, you end up with 0.

    You can fix this by changing your code to

    float frameWidth = 1.f/NumFramesWide;
    float frameHeight = 1.f/NumFramesTall;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need use this method with three distinct classes: Orders, Customers, Suppliers public void
Many people use this method to add animation on switching views. When I try
Trying to use this method (gist of which is use self.method_name in the FunnyHelper
actually i use this method to show similar words for a search request.. $query
When i use this method, its throws illegal state expression on blackberry simulator. protected
i use this method before 1 time. but Now i can not get video
I'd like to use this method to create user-friendly URL. Because my site is
I have an ArrayList of Routine objects and I must use this method to
When I use the this method to initialize a UITabBarItem : - (id)initWithTitle:(NSString *)title
I have this method call I have to use... financial_document.assets.length But financial_document.assets could be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.