R0J0hound's Forum Posts

  • blackhornet

    That's cool. I haven't looked at how you did it but I'm glad you were able to make sense of the code to modify it. Especially since working on plugins haven't been an interest to me for a while now.

  • You have to load the image into a Sprite and then paste it into paster.

    Look at page 60.

  • Yeah, that's all correct.

    Cpu speed and graphics card speed a probably the first two factors. Then again you can look at two different CPUs with the same speed and one will perform better. Same with graphics cards.

  • You forgot the parenthesis.

    (A.x+b.x)/2

  • Sorry I can't verify this but maybe try:

    "Item"&str(StartArray.At(ItemId))

    str() converts a number to text differently than just using & as I recall. The reason was str(), which uses the js method to convert a number to text would often show long decimals like: 0.0999999999. So the default behavior with & would cause it to be prettier like 0.1. Anyways that's my rough reasoning.

  • Yeah, only the first value is used for sorting.

  • The distance() expression only gives you the distance between two points. To get the closest distance between a point and a shape it will be more involved. Take the example of a square shape, you'll need to get the distance from all the corners and all the edges and pick the lowest value.

    Basically you'd setup the imagepoints on your object like this:

    0---1
    |   |
    3---2[/code:p47hmjbr]
    Where 0 is the origin.
    Then to calculate the distances you'd use the distance() expression to get the distance to a point, and for the distance to a line you'd use a vector dot product to see if the the projected point is on the line, then a vector cross product is used to get the distance.
    
    Example here:
    [url=https://dl.dropboxusercontent.com/u/5426011/examples34/closest_dist.capx]https://dl.dropboxusercontent.com/u/542 ... _dist.capx[/url]
    
    Now if that is too much math you can go for an approximate solution:  Put a lot of instances all around the shape you want to get the closest distance to.  It should look like dots going around the object's edge, the closer together the better.  Then you can then do an event like this:
    
    dotSprite: pick closest to  (mouse.x, mouse.y)
    --- set text to distance(dotSprite.x, dotSprite.y, mouse.x, mouse.y)
  • You can either duplicate the play sound action to every place you set the text:

    every 1 second

    --- set text

    --- play sound

    or you could make a function to set the text and only use that:

    every 1 second

    --- function call "set text" ("foo")

    on function "set text"

    --- set text to function.param(0)

    --- play sound

  • It's from the origin of the object that is usually centered in the image editor. You could always add an imagepoint and use Sprite.imagepointx(1) instead of sprite.x.

  • I've tried a few ideas. One is to use a couple globals. For example i've used some thing like this to add three vectors together. (1,0), (2,3) and (5,5)

    global number rx=0
    global number ry=0
    on function "add"
    --- set rx to function.param(0)+function.param(2)
    --- set ry to function.param(1)+function.param(3)
    
    start of layout
    --- function: call "add" (1,0, 2,3)
    --- function: call "add" (rx, ry, 5,5)[/code:1bgzt7vv]
    
    I've also put things in a group and using static variables in cases where only functions in that group needs access. Here's a contrived example:
    [code:1bgzt7vv]group: "number print"
    		static number ret0=0
    		static number ret1=0
    		static number ret2=0
    
    		on function "print2"
    		--- function: call "3rand" ()
    		--- browser: console log : ret0&"."&ret1&ret2
    		--- function: call "3digits" ()
    		--- browser: console log : ret0&"."&ret1&ret2
    
    		on function "3rand"
    		--- set ret0 to int(random(10))
    		--- set ret1 to int(random(10))
    		--- set ret2 to int(random(10))
    
    		on function "3digits"
    		--- set ret0 to 3
    		--- set ret1 to 1
    		--- set ret2 to 4
    
    start of layout
    --- function: call "print2" ()[/code:1bgzt7vv]
    
    Another idea would be to implement multiple returns via an array used as a stack.  It would mirror how you'd do it in assembly language.  On possible example. The cleanup could prove tedious, but it probably could be abstracted away with more functions.
    
    [code:1bgzt7vv]on function "get 10 numbers" 
    repeat 10 times
    --- array: push random(1) to front
    --- function: set return to 10
    
    start of layout
    --- function: call "get 10 numbers"
    --- console log: "number of returned numbers: "&function.returnvalue
    --- console log: "first number: "&array.at(array.width-9)
    --- console log: "second number: "&array.at(array.width-8)
    --- console log: "10th number: "&array.at(array.width)
    --- console log: "cleanup"
    --- array: set size to (array.width-10, 1, 1)[/code:1bgzt7vv]
  • Using a boolean to indicate the first tick and then doing it in the tick function is a cleaner solution to me.

    behinstProto.onCreate = function()
    {
       this.firstTick = true;
    };
    
    behinstProto.tick = function()
    {
       if (this.firstTick)
       {
          this.firstTick = false;
          cr.plugins_.Sprite.prototype.acts.SetAnimSpeed.call(this.inst,0);
       }
    };[/code:3iyvjmxy]
  • I thought on changed is only triggered when the user types something in the textbox. If it would be triggered every time the text is set then we'd run into other issues such as an infinite loop if we made a condition like:

    on text changed

    --- set text to ""

  • You could use a system compare with the layoutname expression.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Use something besides sprite that can have a unique image per instance. I know tiledbg can, or maybe a canvas or paster object. I seem to recall a plugin called unique sprite that can do it too.