My Paddle Won't Move.
Capital J Productionz

I am creating my own version of "Block Breaker" from this tutorial Here but the problem i am having is that my "paddle" does not move when i move my mouse. Here is my code, i tried it exactly how he has written it using "paddle" as the variable, i made sure my object name was the same in the properties as well and it did not work. So i changed the variable name and the object's name to match but nothing is working... Is this code outdated and no longer works or am i just doing something wrong? Here is my current code. 

        wade.stopAudio(wade.soundtrack);
        wade.playAudioIfAvailable('Crunch Sound.mp3');
        wade.loadScene('scene2.wsc', true, clearScene = true, function()
        {
        
          
         // the scene has been loaded, do something here
        var Twizzler = getSceneObject("Twizzler");
        wade.app.onMouseMove = function(eventData)
        {
        // I know that Twizzler is capiatalized, i was trying different things since it did not work as a lowercase. example, var twizzler = blah

                 Twizzler.setPosition(enentData.screenPosition.x, Twizzler.getPosition().y);  
       
       
        };
        
    });

All 7 Comments
Gio

Hi

 

Surely that should work. Have you tried looking in the console (you know, F12) to see if there are any errors? I can see a couple of typos: you have enentData rather than eventData with a v. And it should be wade.getSceneObject('Twizzler');

 

What you call your variable shouldn't matter, as long as the name of the scene object that you pass to wade.getSceneObject() is correct

Capital J Productionz

I fixed the errors you mentioned Gio, here it is.

        wade.stopAudio(wade.soundtrack);
        wade.playAudioIfAvailable('Crunch Sound.mp3');
        wade.loadScene('scene2.wsc', true, clearScene = true, function()
        {
        
          
         // the scene has been loaded, do something here
        console.log("loaded game scene");
        var Twizzler = wade.getSceneObject('Twizzler');
        wade.app.onMouseMove = function(eventData)
        {
                 Twizzler.setPosition(eventData.screenPosition.x, Twizzler.getPosition().y);
       
       
        };
        
    });

I checked out the debugger and got this. 

Use of the Application Cache is deprecated on insecure origins. Support will be removed in the future. You should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details.
inputManager.js:156 The deviceorientation event is deprecated on insecure origins, and support will be removed in the future. You should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details.
inputManager.js:160 The devicemotion event is deprecated on insecure origins, and support will be removed in the future. You should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details.
layer.js:775 'CanvasRenderingContext2D.webkitImageSmoothingEnabled' is deprecated. Please use 'CanvasRenderingContext2D.imageSmoothingEnabled' instead.
wide_3.0.js:811 loading extensions Array[0]
wide_3.0.js:483 FileError is deprecated. Please use the 'name' or 'message' attributes of DOMError rather than 'code'.
behavior_evaluator.html:33 'window.webkitStorageInfo' is deprecated. Please use 'navigator.webkitTemporaryStorage' or 'navigator.webkitPersistentStorage' instead.
behavior_evaluator.html:33 'webkitIndexedDB' is deprecated. Please use 'indexedDB' instead.
wade.js:2741 Uncaught TypeError: callback is not a function
wade.js:2741 Uncaught TypeError: callback is not a function
wade.js:2741 Uncaught TypeError: callback is not a function
wade.js:2741 Uncaught TypeError: callback is not a function
wade.js:2741 Uncaught TypeError: callback is not a function
wade.js:2741 Uncaught TypeError: callback is not a function
wade.js:2741 Uncaught TypeError: callback is not a function
wade.js:2741 Uncaught TypeError: callback is not a function
wade.js:2741 Uncaught TypeError: callback is not a function
wade.js:2741 Uncaught TypeError: callback is not a function
wade.js:2741 Uncaught TypeError: callback is not a function
wade.js:2741 Uncaught TypeError: callback is not a function
wade.js:2741 Uncaught TypeError: callback is not a function
wade.js:2741 Uncaught TypeError: callback is not a function
wade.js:2741 Uncaught TypeError: callback is not a function
wade.js:2741 Uncaught TypeError: callback is not a function
sceneEditor.js:1 '//@ sourceURL' and '//@ sourceMappingURL' are deprecated, please use '//# sourceURL=' and '//# sourceMappingURL=' instead.

I am obviously new to Javascript so i know it's an error some where but can't seem to solve it, have any idea what i am doing wrong? Thanks for all your help by the way. 

foxcode

Hi Capital

I just tested this myself to make sure wade is working correctly, I'm one of the devs.

Try replacing ('scene2.wsc', true, clearScene = true, function()
with just ('scene2.wsc', true, function()

If you actually want to clearn the scene, I think you need to do this, but try the simpler example first with no clearing of the scene
('scene2.wsc', true, function(){//put your stuff here}, null);


 

Capital J Productionz

Hi FoxCode, this is the code i came up with after following your instructions.

 

        wade.stopAudio(wade.soundtrack);
        wade.playAudioIfAvailable('Crunch Sound.mp3');
        wade.loadScene('scene2.wsc', true, function(){clearScene = true}, null);
        
        
          
         // the scene has been loaded, do something here
        console.log("loaded game scene");
        var Twizzler = wade.getSceneObject('Twizzler');
        wade.app.onMouseMove = function(eventData)
        {
                Twizzler.setPosition(eventData.screenPosition.x, Twizzler.getPosition().y);
       
       
        };

 

The "Twizzler" paddle moves now but my play button from scene1 still shows on scene2 but everything else does clear. 

foxcode

Sorry, I was wrong about the null thing, but you should not have clearScene = true ever

This is my test code that works for my object


        // load a scene
        wade.loadScene('scene1.wsc', true, function()
        {
            // the scene has been loaded, do something here
            var obj = wade.getSceneObject("object");
            wade.app.onMouseMove = function(data)
            {
                obj.setPosition(data.screenPosition.x, obj.getPosition().y);
            };
        }, true);

 

To briefly explain
 wade.loadScene takes 4 parameters
fileName, loadingBar, callback, clearScene

so you enter the file name which gives you this

wade.loadScene('scene2.wsc', 


You specify if you want a loading bar, we will set this to true, so now you have this

wade.loadScene('scene2.wsc', true

 

The third parameter is the callback. This is the function that executes once the scene is loaded. This is the part inside the {} brackets. We only want this code to be run after the scene is loaded else we may accidentally try to add events to objects that don't yet exist, for example, the click event on your play button. so with the callback, you have this

wade.loadScene('scene2.wsc', true, function()
{
    // Add your code here, do not clear the scene here
    // onMouseMove etc.....
}


The final part is the clear scene parameter, this is the 4th and final parameter of the function. This will come in the form of the word true added on the end

wade.loadScene('scene2.wsc', true, function()
{
    // Add your code here, do not clear the scene here
    // onMouseMove etc.....
}, true);


^^ This is what your code should look like. Create your event handlers for mouse move inside the callback function, our third parameter. Hopefully this is helpful.

Secret tip: If you still have problems and cannot fix it like this, you can manually call wade.clearScene()
So if you have a play button, in the buttons onClick function, you could add wade.clearScene() before you call load scene again, but that would depend on the rest of your code

Good luck

Capital J Productionz

Thanks FoxCode, this was very helpful and it solved my issue. 

foxcode

Glad I could help :)

Let us know if you have any more problems

Post a reply
Add Attachment
Submit Reply
Login to Reply