Tutorial request

You might have already done this but I have not gone through all the videos, but could you give a code example of how you interact between the js file and editor components.

So if I add a procedural square or png as a scene object. This will be detailed in the .wsc file.

I want to refer to and use the scene objects I place on the scene visually. Other than using the behaviors.

All 4 Comments

Yes that's a good suggestion. As quick answer (but I will do the tutorial too at some point), the easiest way is to use the underscore notation _.objectName

So if you create an object in the editor and call it mySquare, you can use _.mySquare to refer to it from your code. 

To handle any events for that object, you can use member functions called onEventName, so for example:

_.mySquare.onMouseDown = function(data)
    this.setVelocity(data.position); // "this" is mySquare



So I am correct in thinking. You could do something like.

_.myTextSprite.setText("some text");

should work.

You once you do these little things, you can say wade is the best javascript development tool out there. cause you can code and visual do things easily. The screen thing is a big one though cause. I feel like I have to do trial and error. 


Just to clarify, the underscore notation allows you to access SceneObjects by name, not Sprites.

If you have a SceneObject named myText that contains a TextSprite, it would be

_.myText.getSprite().setText('some text');



got it, I am trying to go in through a behavor as the event onscore is called. I can do it the way shown which is my first option, but is not the abstraction of wade. So I am trying to get the nuts and bolts of that sorted.


Correction the game should update the scoreboard, instead of the scoreboard listening to the game as it were.

Post a reply
Add Attachment
Submit Reply
Login to Reply