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 7437129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:21:05+00:00 2026-05-29T10:21:05+00:00

The code below is where I am right now, I’ve made it so I

  • 0

The code below is where I am right now, I’ve made it so I can click a button and change from one sprite on a sprite sheet to another. The fundamentals I’m working out may be crap, I don’t really know what I’m doing! By all means, steer me straight if this is so.

What I want to know is how to loop over all the sprites in my sprite sheet. Currently I can just flip between the first and second one (only one time) via button click.

UIImageView test = new UIImageView();
test.Image = UIImage.FromFile("necromancerSpriteSheet.png");

CGImage img = test.Image.CGImage;
CALayer layer = new CALayer();

layer.Contents = img;
layer.Bounds = new RectangleF(0, 0, 128, 128);
layer.Position = new PointF(150, 250);

UIImageView theImage = new UIImageView();

layer.ContentsRect = new RectangleF(0, 0, 0.33f, 0.33f);
layer.RemoveAllAnimations();
theImage.Layer.AddSublayer(layer);

button.TouchUpInside += (s, e) => {             
    layer.ContentsRect = new RectangleF(0.33f, 0, 0.33f, 0.33f);
    layer.RemoveAllAnimations();
    theImage.Layer.AddSublayer(layer);
};

I would expect the process would be to have all the sublayers loaded/initialized then simply loop over them in some way. I haven’t had any luck figuring out how to achieve this yet though.

Here is my test spritesheet if it helps…
necromancer spritesheet

  • 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-05-29T10:21:05+00:00Added an answer on May 29, 2026 at 10:21 am

    There are many ways of solving this problem, but if you want to use CoreAnimation to drive the animation on the sheet, my suggestion is that you use a keyframe animation (CAKeyFrameAnimation) to drive the animation.

    To simplify things, I would merely put all of the items in a single row, and then use something like:

    var anim = (CAKeyFrameAnimation) CAKeyFrameAnimation.FromKeyPath ("position.x");
    anim.Values = new NSNumber [9];
    var times = new NSNumber [9];
    for (int i = 0; i < 9; i++){
        anim.Values [i] = NSNumber.FromFloat (i*WIDTH);
        times [i] = NSNumber.FromFloat (i/9f);
    }
    anim.CalculationMode = CAKeyFrameAnimation.CalculationDiscrete
    

    You might need to tweak the animation above a little, I did the above without testing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay right now I have too include the code below on every single page
Right now the code below tests for a blank text box. If it is
As of right now I'm using this code below to download files to get
Right now the code below produces the output below it, but how would I
Right now I'm able to do a simple animation using the code below. However,
Right now the code below looks for the author_id and the target_object_id in the
Also, right now whenever I click the 'X button on top right, the dialog
Basically this code below returns the right information, but I need to add the
In the below code var panel=<div name=panel id=panel style=display:inline;position: absolute; margin-left: auto;margin-right:auto;left: 0;right: 0;width:350px;height:
i have the following code below but sometime the serving_description tag isn't there. Right

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.