please put tutorial that bg music works
knightansbert7

Admins sorry for making thread again but,please put tutorial that bg music works on android... because my wc3.ogg is not working.. check my attachments. thank you . my final defense is on this day :(

All 70 Comments
knightansbert7

2nd pic

foxcode

Where it says "Code for this box(click to show)" can you click it, I just want to make sure it's what it's supposed to be.
By the sounds of it the music works fine on pc not android.

Unfortunately it's possible that either the device or browser you are using does not support web audio yet, it is still a relatively new feature. On mobile devices especially, support for it differs widly depending on the browser. If that's the case, it's not something we can solve in code.

knightansbert7

Audio problems is fix now sir fox.  But my game needs 1 more lvl where i can drag the item into thee right recycling bin. Can u help me?

Gio

For each item that you want the player to drag, go to the Functions tab and then select onMouseDown. Paste this code in there:

wade.app.dragging = this;

Then edit app.js. At line 3 (just above this.init = ... ) insert this code:

this.onMouseUp = function()
{
    wade.app.dragging = null;
};

this.onMouseMove = function(data)
{
    if (wade.app.dragging)
    {
        wade.app.dragging.setPosition(data.screenPosition);
    }
};

Finally for the recycle bin, edit the onMouseUp function and paste this code in there:

if (wade.app.dragging)
{
    wade.removeSceneObject(wade.app.dragging);

    // here you can insert code for whatever you want to happen
    // when the player drags the piece of garbage into the bin
}

EDIT: sorry I had missed one bit - updated the code above

knightansbert7

How about the garbage that dragged on the wrong bin.... Like for example a paper is dragged on the glass bin .... Then it will say . opps its paper..and then if a bottle item is dragged on the paper bin ..it will say opps its glass... How to do it on every objects?.  Maybe ill put again lifepoints so that there will be a game over. Then a score... 

Gio

You could add a custom property to each piece of garbage, called type (this is done in the Properties tab). Set the value to glass, paper, etc. as appropriate.

You could do the same for your bins, i.e. add a type property.

The onMouseUp functions of your bins will then look like this

if (wade.app.dragging)
{
    if (wade.app.dragging.type == this.type)
    {
        wade.removeSceneObject(wade.app.dragging);

        // here you can insert code for whatever you want to happen
        // when the player drags the piece of garbage into the bin
    }
    else
    {
        // the wrong type was selected - display a message?
        alert('oops, that was ' + wade.app.dragging.type);
    }
}

 

knightansbert7

I'll try it now sir gio.. Salamat

knightansbert7

how to add score when object is correctly put into the right bin? and how to lose a lifepoints when the object is put in the wrong bin 

knightansbert7

i see

knightansbert7

sir how does the bin knew .. for example ... notebook is put on glass bin it say opss its paper.. then how about a plastic bottle is put in glass bin .. it says same? with paper?  i want it to say opss its plastic...

Gio

I am pretty sure that this should happen already. The message depends on the "type" property of the object that you are dragging.

Are you definitely sure that you have set the type property of your plastic bottle to "plastic"?

knightansbert7

append

if paper= type paper     

if plastic= type plastic

if glass= type glass

 

 

correct?

knightansbert7

check this

knightansbert7

what i mean was if a paper will put on the glass bin ... audio will play its_paper.ogg

 

knightansbert7

if (wade.app.dragging)
{
    if (wade.app.dragging.type == this.type)
    {
        wade.removeSceneObject(wade.app.dragging);

        wade.playAudio('correct.ogg');
        // here you can insert code for whatever you want to happen
        // when the player drags the piece of garbage into the bin
    }
    else
    {
        // the wrong type was selected - display a message?
        wade.playAudio('its_paper.ogg');
    }
}

 

else is not working .. i want when the paper is put on plastic or glass bin ... it will play the wadeapp audio its_paper.ogg and the item will disappear and lifepoints -1   

 

 

 

knightansbert7

and if its correct the score will add 1

Gio

Instead of wade.playAudio('its_paper.ogg');

try this:

wade.playAudio('its_' + wade.app.dragging.type + '.ogg');

As for the score, it should be very similar to what you did for another scene, where you created a scoreText object. You can do the same again or, more conveniently, click the import button on the top bar. It looks like this: 

Select your scene that already contains scoreTet, and then the scoreText object - this will create a copy of it in the current scene.

Edit its onAddToScene function, and type in this code:

this.getSprite().setText(wade.app.score || 0);

Then when the score is correct (in your if statement above)

_.scoreText.getSprite().setText(++wade.app.score);

 

knightansbert7

if (wade.app.dragging)
{
    if (wade.app.dragging.type == this.type)
    {
        wade.removeSceneObject(wade.app.dragging);

        wade.playAudio('correct.ogg');
        // here you can insert code for whatever you want to happen
        // when the player drags the piece of garbage into the bin
    }
    else
    {
        // the wrong type was selected - display a message?
     wade.playAudio('its_' + wade.app.dragging.type + 'paper.ogg');
     wade.removeSceneObject(wade.app.dragging);
        
    }
}

not working

Gio

Nope, it wouldn't work like that... try copying and pasting the code I posted above

knightansbert7

when i put glass on plastic bin its working .. it plays audio its_glass.ogg   ...   but not in paper and plastic objects

knightansbert7
wade.playAudio('its_' + wade.app.dragging.type + '.ogg');
i dont understand how this works
Gio

Right, the value of wade.app.dragging.type is the value of the type property of the object that you are dragging. 

So if the type of the object that you are dragging is glass, wade.app.dragging.type == 'glass'.

If the type of the object that you are dragging is paper, wade.app.dragging.type == 'paper'.

The code above creates a string that contains its_ followed by the type followed by .ogg

It then tries to play an audio file with that name.

Of course this can only work if you have audio files for each type, so its_glass.ogg, its_plastic.ogg, etc.

knightansbert7

how about losing lifepoints when item put on the wrong bin

this.getSprite().setText(wade.app.lives || 3);    is that correct? 

knightansbert7

check my audio

Gio

Some of those files (e.g. Its_paper.ogg) start with an uppercase I. Some others (e.g. its_glass.ogg) start with a lowercase i.

Make sure that all of them start with a lowercase i. As it stands now, the code above tries to play a file called its_paper.ogg but it doesn't exist, because it's called Its_paper.ogg

knightansbert7

uhhh its working now sir... how about lifepoints

knightansbert7

in my scene5 before i drag the object can i put an audio? 

knightansbert7

if (wade.app.dragging)
{
    if (wade.app.dragging.type == this.type)
    {
        _.scoreText.getSprite().setText(++wade.app.score);
        wade.removeSceneObject(wade.app.dragging);

        wade.playAudio('correct.ogg');
        // here you can insert code for whatever you want to happen
        // when the player drags the piece of garbage into the bin
    }
    else
    {
        // the wrong type was selected - display a message?
     wade.playAudio('its_' + wade.app.dragging.type + '.ogg');
     wade.removeSceneObject(wade.app.dragging);
    
        
    }
}

why its_plastic audio is not working?

knightansbert7

its working now... sir how about on my lvl1 lvl2 lvl3 when i click the item i want an audio play like i click a notebook .. its will play notebook.ogg

knightansbert7

Got it.. Only lifepoints on lvl4 needed

knightansbert7

hey sir lifepoints is ok now.. but i dont know how if the score in drag item will get 10 it will open congratzMessage.. its deifferent in finding object true

knightansbert7

sir how to do it when the score in dragging items gets 10 it will visible the congratz message asap

Gio

If you have an object called congratzMessage and that object is initially set to be invisible, then where you do  _.scoreText.getSprite().setText(++wade.app.score); you could do this

 _.scoreText.getSprite().setText(++wade.app.score);
if (wade.app.score == 10)
{
    _.congratzMessage.setVisible(true);
}

 

knightansbert7

Where shud i put  that? 

Gio

where you do  _.scoreText.getSprite().setText(++wade.app.score);

knightansbert7

On my scoreText object  addtoscenefunction?

Gio

I believe you are doing that on the bin's onMouseUp function

knightansbert7

Uhhh thats where i got wrong.. I put if statement but i didnt put the get sprite.. I screwed up in debugging 😭

knightansbert7

if (wade.app.dragging)
{
    if (wade.app.dragging.type == this.type)
    {
       _.scoreText.getSprite().setText(++wade.app.score);
        wade.removeSceneObject(wade.app.dragging);

        wade.playAudio('correct.ogg');
        
 _.scoreText.getSprite().setText(++wade.app.score);
if (wade.app.score == 10)
{
    _.congratzMessage.setVisible(true);
}
    }
    else
    {
        // the wrong type was selected - display a message?
     wade.playAudio('its_' + wade.app.dragging.type + '.ogg');
     wade.removeSceneObject(wade.app.dragging);
     --wade.app.lives;
_.lifeText.getSprite().setText(wade.app.lives);

if(wade.app.lives === 0)
{
    wade.clearScene();
wade.loadScene('gameOver.wsc'); // I'm just clearing scene
    // No lives left, end game
    // restart or anything else you want
}
        
    }
}

 

i think theres something wrong?

Gio

Yes

Go back to what you had before. Just replace 

_.scoreText.getSprite().setText(++wade.app.score);

with the code that I posted above

knightansbert7

Go back to what you had before. <--- i dont understand sir 

Gio

You've just made a change and realized that it didn't work.

Go back to what you had before means "undo that change you've just made"

knightansbert7

if (wade.app.dragging)
{
    if (wade.app.dragging.type == this.type)
    {
       _.scoreText.getSprite().setText(++wade.app.score);
        wade.removeSceneObject(wade.app.dragging);

        wade.playAudio('correct.ogg');
        
    }
    else
    {
        // the wrong type was selected - display a message?
     wade.playAudio('its_' + wade.app.dragging.type + '.ogg');
     wade.removeSceneObject(wade.app.dragging);
     --wade.app.lives;
_.lifeText.getSprite().setText(wade.app.lives);

if(wade.app.lives === 0)
{
    wade.clearScene();
wade.loadScene('gameOver.wsc'); // I'm just clearing scene
    // No lives left, end game
    // restart or anything else you want
}
        
    }
}

 

this code works but no if wadeapp score===10 set congratzmessageVisible

Gio

Right, now you've gone back to what you had before...

 Just replace 

_.scoreText.getSprite().setText(++wade.app.score);

with the code that I posted above

knightansbert7

if (wade.app.dragging)
{
    if (wade.app.dragging.type == this.type)
    {
 _.scoreText.getSprite().setText(++wade.app.score);
if (wade.app.score == 10)
{
    _.congratzMessage.setVisible(true);
}
        wade.removeSceneObject(wade.app.dragging);

        wade.playAudio('correct.ogg');
        
    }
    else
    {
        // the wrong type was selected - display a message?
     wade.playAudio('its_' + wade.app.dragging.type + '.ogg');
     wade.removeSceneObject(wade.app.dragging);
     --wade.app.lives;
_.lifeText.getSprite().setText(wade.app.lives);

if(wade.app.lives === 0)
{
    wade.clearScene();
wade.loadScene('gameOver.wsc'); // I'm just clearing scene
    // No lives left, end game
    // restart or anything else you want
}
        
    }
}

 

 

correct?

knightansbert7

in 3 bins right? mouse up

knightansbert7

uncaught typeerror: cannot read property 'setVisible' of undefined (Sceneobjec,

knightansbert7

i t hink its bug because when i made again a congratzMessage it worked

knightansbert7

sir gio i just want to thank you and let you know that my next project is like angrybird like the unicorn in tutorial :D

knightansbert7

http://www.filehosting.org/file/details/651806/Master%20%20Cleaner%20%20%20Final.zip  sir kindly check my project ... theres some error on other scenes that you only can fixed but its workingly fine..  kindly check it sir thank you... ill wait

knightansbert7

could you fix that sir coz  its stuck at loading screen scene1 to scene2 in my android phone

knightansbert7

sir?

Gio

It worked for me, I didn't see any problem.

What happens exactly? You click to go to the next level, the loading bar appears and then it gets stuck? At what point does it get stuck?

knightansbert7

on android package.. when i click start... it just  loading

knightansbert7

This sir

Gio

As it does work on my phone, I'm not really able to tell you what's wrong with it... the best thing you can do is some debugging, that is create a copy of the scene that fails to load (right-click the file and select Duplicate File), then start simplifying it. It is almost certainly a case of it failing to load some asset... so I would start removing assets from it until it works. Then you will know which image / sound is causing a problem on your phone.

knightansbert7

I uninstalled all apk's of my game .. And also i will try your suggestion thank you

knightansbert7

},
    "scripts": [
        "hiddenObject.js",
        "hiddenObject.js"

 

i found this on my scene3

foxcode

I dont know how that has been added twice, but you can remove one of those lines. Including the same script twice doesn't make sense, but I dont think it would cause any bugs

knightansbert7

could you check my files? why is it bug on my phone

knightansbert7

where to get the assets of your loppy bird game like tutorial .. that unicorn

Gio

Hi

You can download the flying unicorn animation here

I believe for the background we used one of the landscapes in the 2d art pack on our downloads page

I am not sure where the boxes came from though

knightansbert7

thank you ill try to make one also

knightansbert7

sir how to put score and game over?

how to .. like when u open the game then there will be a welcome animated text before the game menu

Gio

Can you check this thread to see if it answers your questions?

Flappy bird count score, game over and restart

knightansbert7

i want my 1st scene to view animated text then game menu

Gio

Could you split the two things? That is, have a scene with your animated text, and when the animation is finished you load the scene with the game menu. For the game menu itself, you can do the same thing you did for your previous game.

For the animated text, I'm going to need some more info. Animated how exactly?

knightansbert7

just like a welcoming animation text ..

knightansbert7

how to make this jumping on the screen.. i will just put this on game menu

Gio

You could create a Path (define it as you want, you can decide where it goes exactly, how quickly, etc), then set your object on the path.

Please refer to this youtube video:

Paths and Tweening

Post a reply
Add Attachment
Submit Reply
Login to Reply