SOLVED: Scaling a created object

Discussion in 'Programming' started by Shizuky, Aug 11, 2019.

  1. Shizuky

    Shizuky Member

    Joined:
    Jul 21, 2019
    Posts:
    25
    Hi , I wanted to create an object in room but I want it to be bigger and tried it with this code: instance_create_layer(320,320,"Text",oPlayer){
    image_xscale=3
    image_yscale=3
    }


    I thought it will scale the object to be bigger when created but the oPlayer is still same.
    How could I make it bigger when created?
     
  2. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    6,906
    Put a with in front of that
     
  3. marasovec

    marasovec Member

    Joined:
    Sep 15, 2016
    Posts:
    325
    2 ways:
    Like TheouAegis said: Using "with"
    Code:
    with(instance_create_layer(320, 320, "Text", oPlayer))
    {
        image_xscale = 3;
        image_yscale = 3;
    }
    
    or using "."
    Code:
    var player_object = instance_create_layer(320, 320, "Text", oPlayer);
    player_object.image_xscale = 3;
    player_object.image_yscale = 3;
    
     
  4. Shizuky

    Shizuky Member

    Joined:
    Jul 21, 2019
    Posts:
    25
    I tried both and it doesn't seems to be working.
    I have it like this:
    [ case quest.pat:
    i++;
    with(oPlayerIntro){
    var inst = instance_place(x,y,inst_673366E4);
    if (inst != noone and !instance_exists(obj_textbox)){
    with(inst){
    show_debug_message("INTROOO")
    room_goto(room17);
    instance_destroy(inst);
    instance_destroy(oPlayerIntro);
    var player_object = instance_create_layer(320, 320, "Text", oPlayer);
    player_object.image_xscale = 3;
    player_object.image_yscale = 3;
    }
    }
    }]
     
  5. NightFrost

    NightFrost Member

    Joined:
    Jun 24, 2016
    Posts:
    1,963
    You have room_goto in the code, so it doesn't matter what the code does, because you'll be switching room afterwards and everything will be in the state presented by target room's editor view.

    (Remember that a room change runs after currently running event ends, not in the middle of code.)
     
  6. Shizuky

    Shizuky Member

    Joined:
    Jul 21, 2019
    Posts:
    25
    Is there a way to create a larger oPlayer and still go to a room? Or I need to rethink it completely to create it sooner?
     
  7. NightFrost

    NightFrost Member

    Joined:
    Jun 24, 2016
    Posts:
    1,963
    You need to message the next room somehow about player size. This could be accomplished through A) set a global variable that is checked in player create, B) have a persitent control object do player spawning as one of its duties (room start event), and before room change set a variable on it to modify player size, or C) make player persistent, but this may be troublesome as it then brings all of its current states to next room (including its position).
     
    Shizuky likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice