Четверг, 25 Апреля 2024, 23:35

Приветствую Вас Гость

[ Новые сообщения · Игроделы · Правила · Поиск ]
  • Страница 1 из 1
  • 1
Форум игроделов » Конструкторы игр и лёгкие в освоении системы разработки игр » Game Maker » Поворот спрайта вокруг определенной точки
Поворот спрайта вокруг определенной точки
Noisy_BoxДата: Пятница, 17 Февраля 2012, 18:37 | Сообщение # 1
частый гость
Сейчас нет на сайте
Как сделать поворот спрайта относительно любой из его точек на определенный градус?
GameMixДата: Пятница, 17 Февраля 2012, 18:48 | Сообщение # 2
старожил
Сейчас нет на сайте
Встроенная переменная image_angle. Подробнее читайте в справке.

Steel Standoff - 2D аркада.
Мои статьи
Noisy_BoxДата: Пятница, 17 Февраля 2012, 19:39 | Сообщение # 3
частый гость
Сейчас нет на сайте
Справка, справка... А нормально ответить видимо не судьба как всегда? И от исходника бы не отказался. Непонятная у этого гм справка.
LunarPixelДата: Пятница, 17 Февраля 2012, 19:48 | Сообщение # 4
старожил
Сейчас нет на сайте
Noisy_Box, а включить мозг не судьба, как всегда? Или поиском воспользоваться, или посмотреть любой пример, в котором есть поворот спрайта?
Code
image_angle - Угол, с которым спрайт будет вращаться. Вы определяете градусы против часовой стрелки.

image_angle=угол поворота, что тут непонятного?! smile


TimKruzДата: Пятница, 17 Февраля 2012, 20:00 | Сообщение # 5
старожил
Сейчас нет на сайте
Нужно уметь пользоваться справкой и знать английский язык, хотя бы на начальном уровне.
Quote (Справка GameMaker)
Sprites and images
Each object has a sprite associated with it. This is either a single image or it consists of multiple images. For each instance of the object the program draws the corresponding image on the screen, with its origin (as defined in the sprite properties) at the position (x,y) of the instance. When there are multiple images, it cycles through the images to get an animation effect. There are a number of variables that affect the way the image is drawn. These can be used to change the effects. Each instance has the following variables:

visible If visible is true (1) the image is drawn, otherwise it is not drawn. Invisible instances are still active and create collision events; only you don't see them. Setting the visibility to false is useful for e.g. controller objects (make them non-solid to avoid collision events) or hidden switches.
sprite_index This is the index of the current sprite for the instance. You can change it to give the instance a different sprite. As value you can use the names of the different sprites you defined. Changing the sprite does not change the index of the currently visible subimage.
sprite_width* Indicates the width of the sprite. This value cannot be changed but you might want to use it.
sprite_height* Indicates the height of the sprite. This value cannot be changed but you might want to use it.
sprite_xoffset* Indicates the horizontal offset of the sprite as defined in the sprite properties. This value cannot be changed but you might want to use it.
sprite_yoffset* Indicates the vertical offset of the sprite as defined in the sprite properties. This value cannot be changed but you might want to use it.
image_number* The number of subimages for the current sprite for the instance (cannot be changed).
image_index When the image has multiple subimages the program cycles through them. This variable indicates the currently drawn subimage (they are numbered starting from 0). You can change the current image by changing this variable. The program will continue cycling, starting at this new index. (The value can have a fractional part. In this case it is always rounded down to obtain the subimage that is drawn.)
image_speed The speed with which we cycle through the subimages. A value of 1 indicates that each step we get the next image. Smaller values will switch subimages slower, drawing each subimage multiple times. Larger values will skip subimages to make the motion faster. Sometimes you want a particular subimage to be visible and don't want the program to cycle through all of them. This can be achieved by setting the speed to 0 and choosing the correct subimage. For example, assume you have an object that can rotate and you create a sprite that has subimages for a number of orientations (counter-clockwise). Then, in the step event of the object you can set
{
image_index = direction * image_number/360;
image_speed = 0;
}

depth Normally images are drawn in the order in which the instances are created. You can change this by setting the image depth. The default value is 0, unless you set it to a different value in the object properties. The higher the value the further the instance is away. (You can also use negative values.) Instances with higher depth will lie behind instances with a lower depth. Setting the depth will guarantee that the instances are drawn in the order you want (e.g. the plane in front of the cloud). Background instances should have a high (positive) depth, and foreground instances should have a low (negative) depth.
image_xscale A scale factor to make larger or smaller images. A value of 1 indicates the normal size. You must separately set the horizontal xscale and vertical yscale. Changing the scale also changes the values for the image width and height and influences collision events as you might expect. Changing the scale can be used to get a 3-D effect. You can use a value of -1 to mirror the sprite horizontally.
image_yscale The vertical yscale. 1 is no scaling. You can use a value of -1 to flip the sprite vertically.
image_angle The angle with which the sprite is rotated. You specify this in degrees, counterclockwise. A value of 0 indicates no rotation. This variable can only be set in the Pro Edition!
image_alpha Transparency (alpha) value to use when drawing the image. A value of 1 is the normal opaque setting; a value of 0 is completely transparent.
image_blend Blending color used when drawing the sprite. A value of c_white is the default. When you specify a different value the image is blended with this color. This can be used to colorize the sprite on the fly. This variable can only be set in the Pro Edition!
bbox_left* Left side of the bounding box of the instance in the room, as defined by its image (taking scaling into account).
bbox_right* Right side of the bounding box of the instance in the room.
bbox_top* Top side of the bounding box of the instance in the room.
bbox_bottom* Bottom side of the bounding box of the instance in the room.

Перевожу:
Quote
Каждый объект имеет спрайт, ассоциированный с ним. Это или одно изображение или контейнер из нескольких. ...блаблабла... У каждого изображения есть следующие переменные:
...блаблабла...
image_angle: угол, на который спрайт поворачивается. Указывается в градусах против часовой стрелки. Значение 0 означает "нет поворота". Эта переменная доступна только в "профессиональной версии"!
...блаблабла...

Quote (Noisy_Box)
относительно любой из его точек

Относительно любой не получится, поворот происходит вокруг левого верхнего угла спрайта. Чтобы повернуть, например, вокруг угла, дополнительно смещай спрайт по осям x и y.

***
Вот тебе пример. Кликай левой/правой кнопкой на квадрат, чтобы повернуть. Пробел - восстановить положение.




Сообщение отредактировал TimKruz - Пятница, 17 Февраля 2012, 20:12
Noisy_BoxДата: Пятница, 17 Февраля 2012, 20:58 | Сообщение # 6
частый гость
Сейчас нет на сайте
Да мне именно поворот нужен напремер вокруг середины нижней стороны квадрата. Или его угла. Чтобы при нажатии на спрайт он вращался вокруг зажатой точки
AnthemДата: Пятница, 17 Февраля 2012, 22:06 | Сообщение # 7
Д'Артаньян
Сейчас нет на сайте
Quote (TimKruz)
и знать английский язык, хотя бы на начальном уровне.
Не, это не нужно


Текстовый контент для вашей игры (бесплатно)
Сценарист, геймдизайнер для Вашей игры
Robin-LocksleyДата: Пятница, 17 Февраля 2012, 22:41 | Сообщение # 8
постоянный участник
Сейчас нет на сайте
Я думаю тут нужен lengthdir_x/lengthdir_y от заданной точки до центра спрайта. Ну а потом просто меняем аргумент dir, и получаем вражение вокруг точки.

GameMaker Easy Menu
Форум игроделов » Конструкторы игр и лёгкие в освоении системы разработки игр » Game Maker » Поворот спрайта вокруг определенной точки
  • Страница 1 из 1
  • 1
Поиск:

Все права сохранены. GcUp.ru © 2008-2024 Рейтинг