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

  • Home
  • SEARCH
  • 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 9110103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:11:47+00:00 2026-06-17T03:11:47+00:00

I’m working on my own tile bliting engine, this one is using hexagonal tiles

  • 0

I’m working on my own tile bliting engine, this one is using hexagonal tiles – but I think it doesn’t differ much from regular tiles.

I have huge x,y array of tiles and they have their x,y coordinates for rendering on canvas, I iterate only the ones that should be visible on canvas in current camera position.

So I’m stuck with scaling and cant resolve this on my own.
Here is my code for drawing tiles on canvas:

public function draw():Void{
    clearCanvas(); //Clear canvas (bitmapData)
            var _m:Matrix;
            iterateTiles(function(_tile:HexTile):Void{ // loop every tile that is visible on screen
                _m = new Matrix();
                _m.translate(_tile.x + cameraPoint.x,_tile.y  + cameraPoint.y);//Get pre calculated tile x,y and add camera x,y
                _m.scale(matrixScale, matrixScale);
                drawToCanvas(_tile,_m);//Send to draw tile on canvas using Matrix
            },true);
        }

This works nice and fast but only problem is it scales tiles from left top corner (like regular scale would work)

Before scale


After scale

My question is how to transform tiles to always scale from center. So if tile 10:10 is in center of screen before scaling, then it should
stay there after scaling.

  • 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-17T03:11:48+00:00Added an answer on June 17, 2026 at 3:11 am

    Sorry, I misunderstood the question, but I think I’ve got it now:

    // Scale the distance from the original point to the center of the canvas
    var xDistance:Number = ((_tile.x + cameraPoint.x) - xCenter) * matrixScale;
    var yDistance:Number = ((_tile.y + cameraPoint.y) - yCenter) * matrixScale;
    
    // Add the distances to the center of the canvas. This is where you want the tile 
    // to appear.
    var x:Number = xCenter + xDistance;
    var y:Number = yCenter + yDistance;
    
    // Because the coordinate is going to be scaled, you need to increase it first.
    x = (1 / matrixScale) * x;
    y = (1 / matrixScale) * y;
    
    _m.translate(x, y);
    

    I have not tested this, I’ve just drawn it out on graph paper. Let me know if it works.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I'm making a simple page using Google Maps API 3. My first. One marker
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,

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.