How to make player restrict of boundries in phaser js game? - phaser-framework

my code is here ( https://www.codepile.net/pile/7mPpA9m0 ) the player is go out of box of canvans how to make it restrict

Just call the method setCollideWorldBounds on the players physics object, than the player should not be able to leave, teh Zone.
In the create function just add this line of code: this.player.body.setCollideWorldBounds(true);

Related

Making and Object uniteractable

So I have a part of my game where the character is selecting an area of the map. And it opening up a panel. I have made it so that happens but an=m now stuck on the other part of it. I want only certain area of the map to be intractable, so that I can bar the player from selecting areas of the map that they aren't ready for. I have no idea how to make game objects in the game uninteractable. I have looked on Stack overflow, Youtube an d the Unity API to no success. Can someone help me with that.
How to make things un-interactable will vary depending on your situation. I'll be presuming that you're map is broken up into a grid of sorts.
The basic setup would involve a bool, probably called 'CanAccessZone'.
Then you'll need a class, to store any access info and popup logic, by popup logic I mean make the element either non-interactable or show a popup, with the shown popup being dependant on 'CanAccessZone'. This class can then be set up by your Map class when the level is loaded, or you could let the popup class grab the necessary values from the Map class.
If you're using Unity's UI buttons for the map pieces, then you could set interactable to false, until you want to let the player access the zone. If you want to display a popup informing the player that they can't access the zone, then your button will be interactable, but the click will delegate to your popup logic method.
It's a similiar principle if you're using gameobjects as buttons. You'd be using any of the OnMouse events to handle click events. https://docs.unity3d.com/ScriptReference/MonoBehaviour.html
Hopefully this'll lead you in the right direction.

custom seekbar/scrubber on a media player UWP

So I'm coding a music player and don't want to use their defualt mediaplayer control panel.
I have a slider object (SeekBar) and I know I can update it to display the postion i am in a current song as such:
SeekBar.Value = (int)PlayMusic.Position.TotalMilliseconds;
So when I call the above the bar move to the exact position I need it to be
So how can I start a thread (async method?) that calls a function that loops the above every millisecond. I'm pretty new and have been trying this for a while.

Which is Right Way to Add Joystick in Unity3d , Adding on Scene Directly or Iniatiating it From Player Scripts

I have to add Joystick control in my Game
I had done with Two Approaches both works well for me , but confused Which one to go with.
1) Initiating Joystick Control from Players Object/Script and getting inputs there.
2) Add Joystick Control Directly to Game Scene and then accessing it in player script by findObjectwithTag and getting inputs .
Calling "Instantiate" and "GameObject.Find" is pretty expensive so in my opinion the efficient way is
1: Add Joystick Control Directly to Game Scene
2: Create a public object inside player and assign "joystick control" from inspector (Editor).

Spotify: Linking tracks on page

How can I link different tracks present in a particular tab on spotify page, so that when clicked on spotify next/previous button the next/previous track is played. Presenlty it is not playing anything if clicked on next button, when it should be starting to play the next track present on the page
My script looks like this,
$.each(allTracks,function(index,track){
models.Track.fromURI(track, function(track) {
models.Album.fromURI(track.album.uri, function(album) {
var single_track = models.Track.fromURI(track.uri);
var single_track_playlist = new models.Playlist();
single_track_playlist.add(single_track);
var pl = new views.Player();
pl.context = single_track_playlist;
if(index==0) {
$("#firstTrack").append(pl.node);
}
.............
.............
Can anyone please guide me on how I should be going around doing this? Thank you in advance
In your case, the context of each Player view is a playlist with that single track. If you want to render your tracks as players, and have them synchronized so that the next track plays after the one before ends, you need to create a custom solution.
You can check this Grid Play Spotify App, that shows an example of how to achieve it. It basically creates custom Player views that respond to certain events triggered by the Player model and other Player views.

How do I make an event in ROBLOX when a specific dialog?

Say I want to make a brick dissapear when a certain dialog choice is selected.
I make an NPC, then I add a dialog tree. It is now set so when a player talks to the NPC, they have the choice to say "Can you make that brick dissapear?". The NPC replies "There you go!"
What would I need to do to make it so when the NPC replies, the brick dissapears?
On roblox?
There's an event in the Dialog object.
DialogChoiceSelected(Instance player, Instance dialogChoice)
This is how you can use it for making a brick "disappear" as long as you have defined the variables "Dialog" and "Brick"
Dialog.DialogChoiceSelected:connect(function(Player, Choice)
if Choice.Name == "BrickChanger" then
Brick.Transparency = 1
end
end)
The argument "Player" is the player who selected that choice, the "Choice" argument refers to the DialogChoice userdata that was chosen.

Resources