Page 1 of 1
Video 1. Game Loops - Problem with Code
Posted: Wed Jun 12, 2013 10:37 pm
by surfer
Hi,
i´m totally new in programming and bought above mentioned course.
I have a problem with this code segment right at the start of the session:
on arrowKey pKey
if pKey is "up" then
set the top of graphic "mygraphic" to the top of graphic "mygraphic" -10
end if
end arrowKey
This error appears:
card id 1002: execution error at line 4 (Chunk: no such object) near "mygraphic", char 53
I checked the code more than twice but i can´t find the mistake nor i understand the error message.
I hope you can understand and help me.
Thanks.
Re: Video 1. Game Loops - Problem with Code
Posted: Wed Jun 12, 2013 11:25 pm
by DarScott
I don't know this video, but maybe I can give you some general hints.
The text graphic "mygraphic" refers to an object expected to be found on the current card. It might be an oval, a square, a polygon or any of several others. Perhaps the video had you create that. And name that.
Each object has a name. You can change the name by editing the properties. Open the object inspector for that graphic by selecting it with the edit tool (pointer-move cursor), and then selecting "Object Inspector" in the Object menu. At the top of the Basic Properties page you will see a field with the label "Name" by it. You can change the name there or confirm that it is correct, that is, "mygraphic" without the quotes.
If the graphic exists and the name is right, then, uh, I don't know. One more familiar with the video might be needed.
Re: Video 1. Game Loops - Problem with Code
Posted: Wed Jun 12, 2013 11:34 pm
by bn
Hi Surfer,
welcome to the forum.
the error messages says: there is not an object graphic "mygraphic"
the object is simply not there.
Either you did not make a graphic "mygraphic" if the "on arrowKey pKey" handler is in the card script or if the handler is in the stack script then you are on a card that has not the graphic.
Where is the script for the arrowKey placed?
Kind regards
Bernd
Re: Video 1. Game Loops - Problem with Code
Posted: Thu Jun 13, 2013 4:07 am
by Newbie4
As the others said, you either did not add a graphic and name it or you did not name it "mygraphic"
To add a graphic use the tools as shown on this page:
https://sites.google.com/a/pgcps.org/li ... graphics-1 Then right-click the graphic, select "Property Inspector" and change the name to "mygraphic" Then it should work
To see a simplified explanation of moving objects see:
https://sites.google.com/a/pgcps.org/li ... ingobjects
note: it moves a different object ( button "box" instead of graphic "mygraphic" in your example
I don't know whether this helps you understand any better but I am offering it up anyway.
Good luck. And welcome to LiveCode