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 / [SOLVED] PlaySprite random position

Author
Message
Rocco Sette
7
Years of Service
User Offline
Joined: 2nd Aug 2017
Location:
Posted: 23rd Jul 2018 22:00
Hi,

When i use PlaySprite in my function, my sprite position have been changed without reason.
The following code is the only place when i change position sprite, without initialisation.

When i comment PlaySprite, all move is fine, but when i uncomment him, sometimes sprites is moved. Why ?
Tween works

The author of this post has marked a post as an answer.

Go to answer

puzzler2018
User Banned
Posted: 23rd Jul 2018 22:22
You if conditions will run throughout

So if the first IF statement comes true it will run

If the 2nd if statement also comes true - then that will run too

Stick and else in there and see what happens - you got your indentations correct
Rocco Sette
7
Years of Service
User Offline
Joined: 2nd Aug 2017
Location:
Posted: 23rd Jul 2018 22:41
But if i want play an animation during a tween ?
puzzler2018
User Banned
Posted: 23rd Jul 2018 22:58
Maybe play the animation on the IF


Rocco Sette
7
Years of Service
User Offline
Joined: 2nd Aug 2017
Location:
Posted: 24th Jul 2018 07:16
Without elseif ?
Rocco Sette
7
Years of Service
User Offline
Joined: 2nd Aug 2017
Location:
Posted: 24th Jul 2018 07:31


I have the same error
Rocco Sette
7
Years of Service
User Offline
Joined: 2nd Aug 2017
Location:
Posted: 24th Jul 2018 07:34
Same error with that code :
Rocco Sette
7
Years of Service
User Offline
Joined: 2nd Aug 2017
Location:
Posted: 24th Jul 2018 08:03
It's strange because with "black idle" it's works, not with walk.

But it's the same number of frames :



fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 24th Jul 2018 08:10
taken from the help file


so in effect these lines

change the dimensions of the sprite this can have an effect on the position of the sprite
using this command


may help if you make sure the offset is always in the centre


another workaround may be to position the sprite again before the sync()
fubar
Rocco Sette
7
Years of Service
User Offline
Joined: 2nd Aug 2017
Location:
Posted: 24th Jul 2018 11:41
You have made an error, i don't use it SetTweenSpriteSizeX, but SetTweenSpriteX
Rocco Sette
7
Years of Service
User Offline
Joined: 2nd Aug 2017
Location:
Posted: 24th Jul 2018 12:00
It's incredible i can use tween perfectly but position change when i uncomment PlaySprite, i have already check all things but i'm sure the problem is from PlaySprite
Rocco Sette
7
Years of Service
User Offline
Joined: 2nd Aug 2017
Location:
Posted: 24th Jul 2018 12:01
Rocco Sette
7
Years of Service
User Offline
Joined: 2nd Aug 2017
Location:
Posted: 24th Jul 2018 12:30
I don't understand... Because the playsprite works with idle but not walk image, i don't understand why...
Rocco Sette
7
Years of Service
User Offline
Joined: 2nd Aug 2017
Location:
Posted: 24th Jul 2018 12:39
PlaySprite(ant_sprite, 4, 0, 1, 4) works
But not :
PlaySprite(ant_sprite, 4, 0, 1, 15) or PlaySprite(ant_sprite, 15, 0, 1, 15) = don't works... (i use 15 subimages)


Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 24th Jul 2018 13:12
Perhaps it would be best to post up an actual example project including the sprite file as we will be guessing as to what your error is otherwise.

I've used Playsprite and tweens together before and not had this issue.

Are the images in the walk animation offset on the x,y axis so the centre of the sprite is no longer where you think? Do you have some other code that is causing the fault etc..
Rocco Sette
7
Years of Service
User Offline
Joined: 2nd Aug 2017
Location:
Posted: 24th Jul 2018 13:38
I think it's my number of frames... Maybe i use this function wrong.

I will try to make a little project for testing
Rocco Sette
7
Years of Service
User Offline
Joined: 2nd Aug 2017
Location:
Posted: 24th Jul 2018 16:29
The file for loaded image is initialisation/anthill.agc
The file that playSprite is map/move/ant.agc
Rocco Sette
7
Years of Service
User Offline
Joined: 2nd Aug 2017
Location:
Posted: 24th Jul 2018 16:31
I forgotten to upload it... Sorry

Attachments

Login to view attachments
Rocco Sette
7
Years of Service
User Offline
Joined: 2nd Aug 2017
Location:
Posted: 24th Jul 2018 18:04
This post has been marked by the post author as the answer.
Someone can remove my attach file ?

I found the solution, sprites bad declared in subimages.txt
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 24th Jul 2018 19:21
you can edit your post and click the delete button next to the attachment
life's one big game
spec= 4ghz, 16gb ram, AMD R9 2700 gpu
Rocco Sette
7
Years of Service
User Offline
Joined: 2nd Aug 2017
Location:
Posted: 24th Jul 2018 20:18
In fact...

I have been search for 5 minutes for find it... Sorry... Thank's !

Login to post a reply

Server time is: 2024-11-23 17:57:01
Your offset time is: 2024-11-23 17:57:01