GameMaker 日本語掲示板

回転と拡縮に対応した円と四角形のdraw関数

0 コメント
views
17 フォロー
function draw_circle_transformed_color(x,y,radius,scaleX,scaleY,angle,color,outline)
{
    var scale     = matrix_build(0,0,0,0,0,0,scaleX,scaleY,1);
    var rotate    = matrix_build(0,0,0,0,0,angle,1,1,1);
    var translate = matrix_build(x,y,depth,0,0,0,1,1,1);
    var m1        = matrix_multiply(scale,rotate);
    var m2        = matrix_multiply(m1,translate);
    
    matrix_set(matrix_world,m2);    
    draw_circle_color(0,0,radius,color,color,outline)    
    matrix_set(matrix_world,matrix_build_identity());
}

function draw_box_transformed_color(x,y,width,height,scaleX,scaleY,angle,color,outline)
{
    var scale     = matrix_build(0,0,0,0,0,0,scaleX,scaleY,1);
    var rotate    = matrix_build(0,0,0,0,0,angle,1,1,1);
    var translate = matrix_build(x,y,depth,0,0,0,1,1,1);
    var m1        = matrix_multiply(scale,rotate);
    var m2        = matrix_multiply(m1,translate);    
    
    matrix_set(matrix_world,m2);    
    var widthHalf  = width / 2;
    var heightHalf = height / 2;
    var x1         = -widthHalf;
    var x2         = widthHalf;
    var y1         = -heightHalf;
    var y2         = heightHalf;
    draw_rectangle_color(x1,y1,x2,y2,color,color,color,color,outline);    
    matrix_set(matrix_world,matrix_build_identity());
}

matrixをうまく使うと、drawしたものを一括で回転、スケール変化させることができるのでむっちゃ便利です(処理は重いかも)

生高橋
作成: 2024/11/16 (土) 21:04:50
通報 ...