Timing of calling "Draw" function

  • Ashley

    Here is the description of timing of calling "Draw" function (reference)

    "Called when Construct wants the instance to draw itself in the Layout View."

    I am curious when to call this draw function by IDE. (perhaps each tick?)

    The use-case is, I have a property to set to color of placeholder. Here is the code to draw that placeholder.

    		Draw(iRenderer, iDrawParams)
    		{
    			// render placeholder
    			iRenderer.SetAlphaBlend();
    			iRenderer.SetColorFillMode();
    			iRenderer.SetColor(this._inst.GetPropertyValue("color"));
    			iRenderer.Quad(this._inst.GetQuad());
    		}
    [/code:38e6ztwu]
    
    The color of placeholder is changed when I set that "color" property. It worked great. 
    But... I had not added code under "OnPropertyChanged" function. Supposing that I should invoke redrawing with new color under "OnPropertyChanged" function.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Draw() is called when the layout view renders, which is usually one-off when something has changed, but can be every tick (e.g. if drag-scrolling).

    The layout view automatically redraws when any property changes, so your code will work without having to add anything in OnPropertyChanged.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)