简体   繁体   English

游戏地形精灵旋转

[英]Game Terrain Sprite Rotation

I'm making an RPG game. 我正在制作RPG游戏。 I'm working on a map editor which I can use to design the game's world. 我正在使用地图编辑器来设计游戏的世界。 Now as I'm creating the sprites, I see that I will have stuff like a beach, where grass meets sand. 现在,当我创建的精灵,我知道我会的东西像一个海滩,那里的草符合沙子。 I make a 32x32 sprite, half of it consisting of my grass sprite and the other half consisting of my sand sprite, respectively. 我制作了一个32x32的精灵,其中一半由草精灵组成,另一半由沙精灵组成。

Now let's say I want to use this same sprite, but it's mirror image. 现在让我们说我想使用相同的精灵,但是它是镜像。 Sand comes first, then grass. 首先是沙子,然后是草。

My map editor saves the map by using JSON, so I can't save the Image, I have to save an URL to retrieve the image when I play my game. 我的地图编辑器使用JSON保存地图,所以我无法保存图像,我在玩游戏时必须保存一个URL来检索图像。 So how can I be sure to save some sort of information that specifies how this image should be drawn, whether it be rotated 180 degrees or it's mirror image? 因此,如何确定要指定此图像绘制方式的信息,无论是旋转180度还是镜像? How can I perform these changes to my image? 如何对图像进行这些更改?

I suggest the JSON used to drive the map/editor should contain information about the orientation of the tile and anything else the map location may need. 我建议用于驱动地图/编辑器的JSON应该包含有关图块方向以及地图位置可能需要的其他信息。 For example: 例如:

{
  "name": "Isle of Dread",
  "locations": [
    {
      "x": 0,
      "y": 0,
      "terrain": "sand",
      "tile": {
        "url": "/tiles/grassy-beach.png",
        "orientation": "north"
      }
    },
    {
      "x": 0,
      "y": 1,
      "terrain": "sand",
      "tile": {
        "url": "/tiles/grassy-beach.png",
        "orientation": "east"
      }
    }
  ]
}

The code for actually rotating and drawing your tile will be dependent upon the technology you are using. 实际旋转和绘制图块的代码将取决于您使用的技术。 Many graphics frameworks have ways to rotate an image. 许多图形框架都有旋转图像的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM