2013-03-08 2 views
0

그래서 저는 Adobe 디렉터를 사용하여 만들고있는 퀴즈를 가지고 있지만 전반적인 환경에 대해 고민하고 있습니다. 나는 정답 각 버튼에 다음 링고 스크립트를 추가 해요Adobe Director - Lingo Quiz

:

on mouseDown 
    global gscore 
    set gscore = gscore + 1 

그리고 마지막 단계에, 내가 획득 한 포인트를 확인하고 적절한 스프라이트를 표시하려면 다음 링고 스크립트를 사용

그 결과.

on enterFrame 
    if gscore = 0 then set the memberNum of sprite (3) to 154 
end if 
    if gscore = 1 then set the memberNum of sprite (3) to 155 
end if 
    if gscore = 2 then set the memberNum of sprite (3) to 156 
end if 
    if gscore = 3 then set the memberNum of sprite (3) to 157 
end if 
    if gscore = 4 then set the memberNum of sprite (3) to 158 
end if 
    if gscore = 5 then set the memberNum of sprite (3) to 159 
end if 
end 

그래서 내 오류가 더 선언 된 변수가 존재하지 말 것,하지만 글로벌 권리인가? 그래서 어떻게 그것을 인식하지 못합니다. 첫 번째 스크립트는 정답에 해당하는 버튼에 붙어 있으며, 각 버튼에는 다음 질문으로 보내주는 별도의 스크립트가 있습니다. 결과를 표시하기위한 마지막 단계는 gscore의 값에 따라 특정 사용자 정의 스프라이트를 표시해야합니다.

답변

0

설명해 보면 알 수 있습니다.

완전한 if 문으로 만들려면 모든 끝을 제거했습니다. 값을 0으로 선언하는 데 사용되는 첫 번째 스크립트에서 전역 변수를 설정합니다. 그런 다음 나중에 증가 시키면 이전에 정의 된 동일한 이름의 전역 변수에 추가됩니다.

내 문제는 전역 변수 인스턴스 기본값이 무효라고 생각합니다.

1

당신이 해결책을 찾았 기 때문에 기쁘게 생각합니다. 또 다른 접근법은 if ​​문을 전혀 사용하지 않는 것입니다. 귀하를 enterFrame 스크립트는 다음과 같이 읽을 수 있었다 :

를 enterFrame 스프라이트 (3) .memberNum = 154 + gscore 끝

0
on exitframe me 
    global gscore 

에.

if gscore = 0 
    set the memberNum of sprite (3) to 154 
else if gscore = 1 then 
    set the memberNum of sprite (3) to 155 
else if gscore = 2 then 
    set the memberNum of sprite (3) to 156 
else if gscore = 3 then 
    set the memberNum of sprite (3) to 157 
else if gscore = 4 then 
    set the memberNum of sprite (3) to 158 
else if gscore = 5 then 
    set the memberNum of sprite (3) to 159 
end if 

end 
관련 문제