Image

Your GameObject which contains Image component, need to be the a child of GameObject which contains a Canvas component

Introduction

Your image gonna get the size of your GameObject world scale and image position gonna set at your GameObject world position.

Change color

You can see the color definition

KapEngine::Tools::Color col(10, 10, 10);

myImage.setColor(col);

No Images

If you do not set a path for an image, you component will be set only for color. There is no code to write to set it without image.

If your image conatins an image and you want only a color, you just have to set path to nothing ("").

Image

To set an image path in your Image component, there is 2 things to do :

  • First one : set the path

myImage.setPathSprite("my/path.png");
  • Second one : set the rectangle of your image :

//way 1
myImage.setRectangle({0, 0, 100, 100});
//way 2
KapEngine::Tools::Rectangle rect;
rect.setPos({0, 0});
rect.setSize({100, 100});
myImage.setRectangle(rect);

here, your image have a size of 100x100 and your want to get all image.

Last updated