Creating an animati...
 
Notifications
Clear all

Creating an animation using a texture atlas

1 Posts
1 Users
0 Likes
48 Views
(@iphan)
Active Member
Joined: 4 weeks ago
Posts: 2
Topic starter  

Ive had this idea to create an animation that uses a single image atlas controlled via its coordinates to translate it to the location of each frame. This would be acheived with a timer that begins once a specified property is triggered. The timer ticks at a set interval increasing the value of a varible from frame 1-10 looping and is then translated into the respective coordinates. Below is a (very rough) outline that works in visual studio

The thing i need the most help with is that the "setInterval" function is not recognized within Simhub Java, so ill need an alternative way of creating this timer. Additionally the "$prop('SystemInfoPlugin.Uptime')" property that was used in a solution regarding the lack of a setInterval function is also no longer available due to an update. Im also a complete beginner in java so im stumped.

Any help or ideas would be greatly appreciated 😀 

My garbo code

let frame = 0;

let rpmShiftLight = true

//rpmshiftLight will be controlled via a game property but is set to true for testing//

function frameCounter() {
frame++;
if (frame === 1) {
console.log('540');
}
else if (frame === 2) {
console.log('1080');
}
else if (frame === 3) {
console.log('1620');
}
else if (frame === 4) {
console.log('1260');
}
else if (frame === 5) {
console.log('2700');
}
else if (frame === 6) {
console.log('3240');
}
else if (frame === 7) {
console.log('3780');
}
else if (frame === 8) {
console.log('4320');
}
else if (frame === 9) {
console.log('4860');
}
else if (frame === 10) {
console.log('5400');
}
if (frame > 9) frame = 0;
}

//console logged values would instead be result values//

if (rpmShiftLight) {
setInterval(frameCounter, 100);
}
else {
frame = 0;
}

//frame 0 would have a coord value off screen//


   
Quote
Share: