![]() |
|
|||||||
| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
| Questions & Help Needed Post any question regarding Basic4ppc. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
I hope I don't fill this forum with stupid questions. So do you.
I have used... if sprite.IntersectsPoint(x,y) =True then sprite.direction=90 and have placed it in Timer1.tick in the example program. I have stepped and used the watch. The sprite position goes through the x,y position (at one point being equal) and never becomes true. What am I not doing please? Also can I drop the = True? As an aside the debug watches are brilliantly easy to use, wow what a pleasure. |
|
||||
|
You can see the behavior of IntersectsPoint in the Walking Character example by changing the Timer1_Tick code to:
Code:
Sub Timer1_Tick
'Manually change the current frame.
sprite.CurrentFrame = (sprite.CurrentFrame + 1) Mod 8 + 8 * direction
If sprite.IntersectsPoint(100,100) Then form1.Text = sprite.X & " " & sprite.Y
gw.Tick
End Sub
Quote:
If it still doesn't work, please post some of your code so we will be able to help. BTW, your questions are good questions and I'm sure that the answers will help other users as well. |
|
|||
|
Thank you for your reassurance Erel.
The following is a slightly modified Sprite example provided with B4PPC for learning purposes. In the App_Start I set cw.direction to 0 and x,y to 48,76. cw.velocity=1, Then I move one pixel in X each tick. The sprite moves perfectly and the watch shows the correct x,y including the target 176,76 and beyond. I cannot see that putting the test after the tick would have an effect. Sub Timer1_Tick gw.Tick 'VERY IMPORTANT: causes the GameWindow to advance to the next step. tick = tick + 1 If tick Mod 50 = 0 Then gw.DeleteMarkedSprites If cw.IntersectsPoint(176,76) = True Then cw.direction = 90 End Sub [EDIT] I have put the intersect line in the walking sample and it doesn't work, however, without pressing any buttons, just stepping the code, it changes direction of its own accord at x=161 which is not the edge of the screen. ( If it is then I can't see where it has been set) Even so 156 is < 161 I must be missing something here. I set direction to 0 and sprite.x to 90 and sprite.y to 76 Sub Timer1_Tick 'Manually change the current frame. 'sprite.CurrentFrame = (sprite.CurrentFrame + 1) Mod 8 + 8 * direction 'If sprite.IntersectsPoint(120,100) Then form1.Text = sprite.X & " " & sprite.Y If sprite.IntersectsPoint(156,76)=True Then sprite.direction = 90 gw.Tick End Sub Any pointers please? [EDIT-1] Weirder still, if I simply change the number 76 to 77 in intersects line in the above code the sprite starts in direction 270, change it back to 76 and it reverts to direction 0 Now I am baffled. Last edited by enonod : 04-29-2008 at 08:51 AM. |
|
||||
|
It seems to work fine.
Please try the attached code. The WalkingChar example uses the CollisionEdge event to change the character direction. |
|
|||
|
Well I must be totally dense. I appreciate that the attached walkingchar did work, I tried it when you first mentioned it. I must be misunderstanding because I am not trying to use an edge. I am trying to choose a point anywhere on screen, send a sprite travelling through it and expect an event when it arrives at it.
To do this I expected to use If sprite.IntersectsPoint(156,76)= but received the unexpected results mentioned above. I wanted to understand (especially the weirder part) what was going wrong and why. Not find an alternative. Why dense? Because I cannot see the connection between the edge (which seem to be constants) detection and the intersects point. If you be a bit more explicit I would be grateful. |
|
|||
|
I apologise but think we are talking at cross purposes and have got out of sync somehow.
Quote:
If it is incorrect use, then please tell me that I have chosen the wrong keyword and put me right. I wish to change direction at pre-programmed chosen points, not edges. If I have not made myself clear please tell me. ![]() Thank you. |
|
|||
|
Thank you for your comment. The code was posted and I did say that it was a simple modification to the Sprite example program provided with B4PPC. The modification is posted and the results I received (one of them odd).
I don't see what more I can do. Here it is again... I set direction to 0 and sprite.x to 90 and sprite.y to 76 Sub Timer1_Tick 'Manually change the current frame. 'sprite.CurrentFrame = (sprite.CurrentFrame + 1) Mod 8 + 8 * direction 'If sprite.IntersectsPoint(120,100) Then form1.Text = sprite.X & " " & sprite.Y If sprite.IntersectsPoint(156,76)=True Then sprite.direction = 90 gw.Tick End Sub The edit can be seen with the commenting out and the replacement line. I am not for one moment suggesting that I haven't written something stupid or missed something out. I simply posted the code and sought help. Then the conversation appeared to go onto edges. Have I still not made it clear? Thank you. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Newbie: animation | texaspoker11 | Questions & Help Needed | 3 | 11-05-2008 06:43 PM |
| Sprite Z Priority | fjsantos | Questions & Help Needed | 4 | 07-20-2008 06:43 PM |
| Newbie Question | Stevenator65 | Questions & Help Needed | 9 | 05-30-2008 09:53 PM |
| Newbie Questions | Bruno | Questions & Help Needed | 2 | 05-05-2008 07:45 PM |
| Newbie questions | stratus | Questions & Help Needed | 2 | 11-13-2007 02:21 PM |