Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(3 edits)

set_scale partially works, but seems to only scale the X dimension (while padding elements as if they were unscaled) for my container_h. These are vector images, if that matters.

I'll include my code, but as a warning it's very split up. I'll try and copy all the relevant snippets.
Both attempts (using a manual workaround and using set_scale) are included here. The only difference (aside from the two sections in the first block) is the last line of the first block, which calls uiContainerToElement instead of uiContainerImagesToElements when using set_scale.


        for (var i = 0; i < ds_list_size(_unit.actions); i++){
            var _action = ds_list_find_value(_unit.actions, i);
            var _sprite = _action.iconSprite;
            
            var _element = auto_image(_sprite);
            
            //SET_SCALE IMPLEMENTATION
            _element.set_scale(0.1);
             actionsSubContainer.add(_element);
            
            //MANUAL WORKAROUND IMPLEMENTATION
            /**           
            _element.set_visible(false);
            _element.staticScale = 0.1; //Easiest to toss a new field into the struct for reference later
            
            actionsSubContainer.add(_element);
            actionsSubContainer.add_space(-sprite_get_width(_sprite)*0.9);
            
            array_push(_actionImagesArray, _element);
            **/
        }
        
        actionsSubContainer.step(600*global.uiScale, (_yBase + 50) * global.uiScale);
        
        uiElements = array_concat(uiElements, uiContainerImagesToElements(actionsSubContainer, _actionImagesArray));


function uiContainerImagesToElements(_container, _images){
    
    var _array = [uiContainerToElement(_container)];
    
    for (var i = 0; i < array_length(_images); i++){
        var _subElement = createEmptyUIElement();
        var _imageElement = _images[i];
        
        _subElement.drawFunction = method({_imageElement}, function(_element){
            draw_sprite_ext(_imageElement.get_sprite(), 0, _imageElement.get_bbox_left(), _imageElement.get_bbox_right(), _imageElement.staticScale, _imageElement.staticScale, 0, c_white, 1);
        });
        array_push(_array, _subElement);
    }
    
    return _array;
}


function uiContainerToElement(_container){
    var _element = createEmptyUIElement();
    
    _element.drawFunction = method({_container}, function(_element){
        _container.draw();
    });
    
    return _element;
}


    if (true) {
        for (var i = 0; i < array_length(uiElements); i++){
            uiArray[i].drawFunction(uiElements[i]);
        }
    }

Correction - set_scale works for the y axis as well. I left out the second scale argument, and forgot that GML doesn't throw syntax errors for that sort of thing. Once this was fixed, the padding behaved as expected. Seems to be good for now!

Perfect!  I'll have to see if I can find a reason I commented that out and maybe undo that in the next update :)


Thanks!