Please view the project here…
Link to the project or level: [Code.org - Game Lab]
What I expect to happen: [The student wants to be able to click on the dollar bill one time and have it turn into a basketball. Then use World.mouseX and World.mouseY to grab the ball and carry it over to the basketball hoop in the Court to score a point in the card game. ]
What actually happens: [Upon clicking the dollar bill, the pre-clicking value is being added as it should ( as noted in the debugging text…however, the basketball will only show up for a moment and then disappear. It will not stick around long enough for them to be able to play the game or drag the ball across the screen. ]
What I’ve tried: [
mousePressedOver(Sprite) all by itself – this causes the basketball points to add up according the frame rate increments and makes the point additions out of control when the user carries the ball over to the basket using World.mouseX and World.mouseY.
Only by using mouseWentDown and mousePressedOver(Sprite) did it control the point increments as one point at a time. However, it broke the ability for the student to hover and carry the basketball. It fixed one problem, but created another problem.
mouseDown(“Left”) && the x,y values of the dollar bill sprite – also created out of control points according to frame rate increments.
All the above examples are even after creating the variables at the top OUTSIDE of the draw loop:
var moneyClick = 0;
var gamePoints = moneyClick;
…to try to slow the point incrementing down and provide some kind of control.
Still both mouseDown(“Left”) and mousePressedOver(sprite) increment out of control. The only one that does not is mouseWentDown – it controls the point system correctly. However, it also, makes the period of time that the mouse is on the sprite so short the basketball no longer shows up or allows the hover of World.mouse.X or World.mouseY.
Please advise, thank you.