Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / suspending a sprite

Author
Message
kirtn14
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location:
Posted: 29th Jan 2012 18:53
i want to suspend a sprite in mid air for a few seconds and then let it fall, is this possible?

kirtnicholls
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 29th Jan 2012 19:35
Yes just make it a dynamic physics sprite when you want it to fall and a static one when you want it to stay still.

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 29th Jan 2012 19:37
SetSpritePhysicsOff( iSpriteIndex )
SetSpritePhysicsOn( iSpriteIndex )

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 29th Jan 2012 19:38
Ninja'd - 2 solutions for the price of one, depending on whether you want it to interact or not.

kirtn14
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location:
Posted: 29th Jan 2012 20:02
Can I do that on a timer because I want to make a times reaction like 1 every 10 seconds for example

kirtnicholls
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 29th Jan 2012 21:21 Edited at: 29th Jan 2012 21:27
Yes, you can change the state of a sprite whenever you like.

EDIT: Just to add to the code slightly-
setSpritePhysicsOn(spriteID, 1) `the 1 makes a static sprite
setSpritePhysicsOn(spriteID, 2) `the 2 makes a dynamic sprite
setSpritePhysicsOn(spriteID, 3) `the 3 makes a kinematic sprite

Static doesn't move but other physics sprites will bounce off it (like a brick wall)
Kinematic can be given a velocity (speed) and other physics sprites will bounce off it (like a... moving brick wall)
Dynamic sprites will bounce off all other physics sprites (like a bouncy ball)

The properties of all physics such as mass (weight) and restitution (bounciness) can be set using the various commands for physics sprites.

There will be an introduction to Physics sprites in this month's AppGameKit Bitesize tutorial in the February newsletter (out in a few days). It doesn't cover everything but it's a start.

kirtn14
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location:
Posted: 1st Feb 2012 09:10
I need it on a mass scale so it suspends every physics command, if anyone knows that?

kirtnicholls
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Feb 2012 09:54
Yes, just use:
stepPhysics(0)

This will stop physics from being updated for ALL physics sprites for each loop it is called. What it effectively does is tell physics to update by zero seconds, when "sync()" is later called it does not automatically update the physics system as it sees it has already been done.

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 1st Feb 2012 12:14
Any idea what happens when you restart? Does it continue where it left off, or do you get one huge chaotic explosion of activity due to the time difference between this step and the last?

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Feb 2012 12:21
There is no massive jump. I use this in my main project when I pause the game.

kirtn14
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location:
Posted: 3rd Feb 2012 21:07
I've used I an it doesn't work it just continues why is this?

kirtnicholls
kirtn14
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location:
Posted: 3rd Feb 2012 21:18
ive added it to this


and it wont work, am i missing somthing simple?

kirtnicholls
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 3rd Feb 2012 21:42
You need to call it every loop, something like this:


kirtn14
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location:
Posted: 3rd Feb 2012 22:05
:'o i idolise you!!!! how do i set it back to nomal? do i change the step physics to another number

kirtnicholls
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 3rd Feb 2012 22:15
No just set PAUSE to zero. That way you don't call stepPhysics() and physics is progressed by the sync() command as usual.

Glad to help

kirtn14
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location:
Posted: 3rd Feb 2012 22:41
[/code]
if GetPointerState()
x# = GetPointerX()
y# = GetPointerY()

if GetSpriteHit(x#, y#) = back
SetSpriteImage(back, backImg)
endif
endif

if GetPointerReleased()
x# = GetPointerX()
y# = GetPointerY()

if GetSpriteHit(x#, y#) = back
SetSpriteImage(back, backImg)
puase = 0
setspritecolor (back,0,0,0,0)
setspritesize (helppage,0,0)
setspriteposition (pausea,90,3)
pauseb = loadimage ("pause.png")
sprite = createsprite (pausea)
setspritesize (pauseb,10,10)
setspriteposition (pauseb,90,3)
setspriteposition (pausea,90,3)
setvirtualjoystickposition (1,90, 88)
endif
endif
[code]

would that be it because the sprite is still not moving

kirtnicholls
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 4th Feb 2012 00:42 Edited at: 4th Feb 2012 00:43
Could you post something I can compile? It's quite hard to guess without the full code (or a working example)...

The code you have posted does not really give enough info.

EDIT: you have spelt pause wrong at this line;


Login to post a reply

Server time is: 2024-11-23 01:12:56
Your offset time is: 2024-11-23 01:12:56