Browse Source

Updated examples.

woollybah 6 năm trước cách đây
mục cha
commit
b00a19a133
2 tập tin đã thay đổi với 32 bổ sung1 xóa
  1. 3 1
      hook.mod/doc/addhook.bmx
  2. 29 0
      hook.mod/doc/allochookid.bmx

+ 3 - 1
hook.mod/doc/addhook.bmx

@@ -5,7 +5,9 @@ Function MyHook:Object( id:Int,data:Object,context:Object )
 	Global count:Int
 	
 	count:+1
-	If count Mod 10=0 Print "Flips="+count
+	If count Mod 10=0 Then
+		Print "Flips="+count
+	End If
 	
 End Function
 

+ 29 - 0
hook.mod/doc/allochookid.bmx

@@ -0,0 +1,29 @@
+SuperStrict
+
+Global myHookID:Int=AllocHookId()
+
+' This function will be called everytime RunHook is executed due to the AddHook action below
+Function MyHook:Object( id:Int,data:Object,context:Object )
+	Global count:Int
+	
+	count:+1
+	If count Mod 10=0 Then
+		Print "Flips="+count
+	End If
+	
+End Function
+
+'Add the MyHook function to our hook ID
+AddHook myHookID,MyHook
+
+'Some simple graphics
+Graphics 640,480,0
+
+While Not KeyHit( KEY_ESCAPE )
+
+   Cls
+   DrawText MouseX()+","+MouseY(),0,0
+   RunHooks myHookID, Null
+   Flip
+
+Wend