Video 1. Game Loops - Problem with Code

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
surfer
Posts: 1
Joined: Wed Jun 12, 2013 10:19 pm

Video 1. Game Loops - Problem with Code

Post by surfer » Wed Jun 12, 2013 10:37 pm

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.

DarScott
Posts: 227
Joined: Fri Jul 28, 2006 12:23 am
Contact:

Re: Video 1. Game Loops - Problem with Code

Post by DarScott » Wed Jun 12, 2013 11:25 pm

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.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: Video 1. Game Loops - Problem with Code

Post by bn » Wed Jun 12, 2013 11:34 pm

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

Newbie4
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 332
Joined: Sun Apr 15, 2012 1:17 am
Contact:

Re: Video 1. Game Loops - Problem with Code

Post by Newbie4 » Thu Jun 13, 2013 4:07 am

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
Cyril Pruszko
https://sites.google.com/a/pgcps.org/livecode/
https://sites.google.com/a/setonhs.org/app-and-game-workshop/home
https://learntolivecode.com/

Post Reply