I was wondering is there was a way to control the volume of something with a
slider so that if the slider was one the value 0 there would be no sound, and
if it was on 100, the sounds was as high as it could go
For the script, I tried something like "set the playLoudness of player 1 to
value" Which obviously didn't work, and so yeah, I'm asking for your help..
Works fine here.
on scrollbarDrag theValue
set the playLoudness of player 1 to theValue
end scrollbarDrag
Of course you need set the startValue of the slider to 0, and the endValue to 100.
Related
The goal is to enable the player to drow the patch for the character.
So I start with simple think, set value for cell(0, 0) in tilemap
and replace the value when the user clicks on it
and it works as expected.
But when I change the camera zoom and try it again it set value in another cell:
I was trying to multiple/divide the click position by the zoom value but it also not resolve the problem
Can anyone give me the hint on how should I handle that?
repo: Github
Once you zoom, the coordinates you get from the input event (screen coordinates) do not match the world.
If you have an input event, the recommended way to do this is with make_input_local:
tilemap.world_to_map(tilemap.make_input_local(event).position)
However, if you don't, but you have screen coordinates, you can do this:
var transform = tilemap.get_canvas_transform() * tilemap.get_global_transform()
tilemap.world_to_map(transform.affine_inverse() * screen_coordinates)
I'm new to coding in general and I'm trying to make a sprite change texture so it has a walking animation but I can't seem to figure out how to apply a wait() or something to my code.
if Input.is_action_pressed("move_up"):
vel.y -= 1
facingDir = Vector2(0, -1)
$LilBoiTexture.texture = load("res://LilBoiAssets/LilBoiBackward.png")
$LilBoiTexture.texture = load("res://LilBoiAssets/LilBoiBackward2.png")
Any help is appreciated. I'm trying to change from the first texture to the second one within idk 0.5, or something ill mess with it if i can figure out what to do.
There is an easier way of doing this instead of changing sprite image manually. You can use "AnimatedSprite" node as shown in the tutorial. Here are the steps:
1- Add an AnimatedSprite node to your character.
2- In properties of AnimatedSprite, Frames-> select new SpriteFrames.
3- Click SpriteFrames you just created, another menu will appear at the bottom of editor. Drag and drop your animation images to center of this menu.
4- Change animation name from default to something else (for example walkback).
5- In your code you just need to do this:
if Input.is_action_pressed("move_up"):
$AnimatedSprite.play("walkback")
else:
# you can also play an idle animation if you have one
$AnimatedSprite.stop()
I am trying to learn how to build a simple platform game with Phaser, but I am having trouble getting the player to jump.
I can see that it is detecting when the "up" button is being pressed, but for some reason the player does not move. My jump code is identical to other examples I have seen, so I am assuming the problem is elsewhere in the file. Do I perhaps need to change the player's gravity or something? I was also wondering if it could be because the game thinks the player is colliding with a wall?
Here is a codepen:
https://codepen.io/moorehannah/pen/RXRroK
and this is the specific code for the jump:
if (this.cursor.up.isDown && this.player.body.onFloor) {
this.player.body.velocity.y = -320;
console.log("up");
}
The tutorial I followed is this one:
http://www.lessmilk.com/tutorial/2d-platformer-phaser
Any help would be greatly appreciated!
The gravity may be too high. You could see if changing onFloor to standing works, or you could even use this.player.body.blocked.down
I’ve built an application in Livecode where there are nine buttons on a card. Eight of the buttons play short music samples and have a variable that holds the number of times the button was pushed. Holding down the mouse button allows the buttons to be dragged around the card as well. The ninth button starts a script that surveys the variables associated with the eight sample buttons and ensures that all the samples have been listened to at least once. The script puts the eight variables into one variable and then checks to see if they are empty. If they are, the script returns an error message prompting them to make sure they have listened to all the samples. The problem I’m having is that this works for all but one of the buttons – the one associated with variable gVar08. If this button has not been pressed, gVar08 remains empty and does not trigger the error message. I can’t figure out why. The scripts associated with the sample button and the evaluation button are provided below.
#Code for music sample button
global gVar08
on mouseDown
wait 30
if the mouseClick then
play audioClip "samples/C1/C1-8ConcertoForViolinStringsAndHarpsichordInGR202IAllegroMolto.wav"
set the filename of image "icn08" to "icons/if_abstract_symbol-03_1571964a.png"
add 1 to gVar08
else
grab me
end if
end mouseDown
#Code assigned to 9th button: Check to see if all samples played at least 1x
global gVar01, gVar02, gVar03, gVar04, gVar05, gVar06, gVar07, gVar08, gErr01
local sClct
on mouseUp
put gVar01, gVar02, gVar03, gVar04, gVar05, gVar06, gVar07, gVar08 into sClct
repeat for each item local in sClct
if local = "" then
answer "Have you listened to all of the samples? Be sure to play them all."
add 1 to gErr01
break
end if
end repeat
end mouseDown
You need a comma and “” after gVar08 in the list. When it is empty, the list ends with 7. Adding a this should always include the last value even if empty.
Since local is a reserved word, have you tried using a different variable?
I couldn't get your Music Sample button code to work, probably due to the mouseClick function within a mouseDown handler not triggering, so I came up with this option:
global gVar08
local sMove
on mouseUp
if sMove then
put empty into sMove
exit to top --Avoids playing the audio and adding 1 to gVar08 on move
end if
play audioClip "samples/C1/C1-8ConcertoForViolinStringsAndHarpsichordInGR202IAllegroMolto.wav"
set the filename of image "icn08" to "icons/if_abstract_symbol-03_1571964a.png"
add 1 to gVar08
end mouseUp
on mouseStillDown
if the mouse is down then
put "true" into sMove
grab me
end if
end mouseStillDown
Hope this helps.
Paul
This is very simple so I'm not sure why I can't do this. All I want to do it position some UIImageViews when my app becomes active. I had been using CGAffineTransformMakeTranslation but I can now see that this is not correct because it moves the view a set amount rather than moving it to a set position. What should I be using?
You could just change the frame of your UIImageView to:
set the x and y origin of the frame to the position you want your
UIImageView to be placed with respect to the containing view.
keep the width and height of your UIImageView the same
Something like this:
imageView.frame = CGRectMake([desired x coordinate], [desired y coordinate], imageView.frame.size.width, imageView.frame.size.height);